0

Ok so i have a program using JFrame when ever i add more than 2 classes in the frame one disappears? How can i add more than 1 class with one of them to dissappear?

Tester Class

public class TestYourFace
{
 
 public static void main(String args[]) {
      JFrame frame = new JFrame();
      frame.setSize(850,850);      
      frame.setTitle("Choose YOUR Features?");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      Face1 Component = new Face1();
      Hair1 Component2 = new Hair1();
      frame.add(Component);
      frame.add(Component2);
      frame.setVisible(true);
  }
}

Classes i want to combine under 1 Frame

Class1

public class Face1 extends JComponent
{
    Shape Head = new Ellipse2D.Float(0, 50, 0, 150);
    public void paint(Graphics g) 
    {
        Graphics2D g2 = (Graphics2D)g;
    
        int Red1 =  205;
        int Green1 = 175;
        int Blue1 =  149;
        Color lightBrown = new Color(Red1, Green1, Blue1);
        
        g2.setColor(lightBrown);
        g2.fill(Head);
    }
}

Class2

public class Hair1 extends JComponent
{
    Shape Hair = new Rectangle2D.Float(0, 0, 50, 50);
    public void paint(Graphics g) 
    {
        Graphics2D g2 = (Graphics2D)g;
    
        int Red1 =  205;
        int Green1 = 175;
        int Blue1 =  149;
        Color lightBrown = new Color(Red1, Green1, Blue1);
        
        g2.setColor(lightBrown);
        g2.fill(Hair);
    }
}
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by mKorbel
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.