First GUI, question

Ok don’t laugh … :slight_smile:

I want to make a window with 3 parts in it. The left area will contain a drawing, the right a list of some sort, and the bottom area will contain text.

Does it make sense for me to create a JFrame, then use panels from BorderLayout to setup the three different areas?

Thanks.

Chris

Yes.

Ok, I have used the BorderLayout and set up a window with 3 panels each doing something different (JTexField, JList, and a JLabel as a placeholder for the area which will display graphics). For the graphics part do I just get a “graphics g” object added to the panel and start drawing? Sorry, I’m very new and am not understanding all of what panels are capable of and how to set them up.

Thanks yet again!

Chris

Use a custom subclass of JComponent or JPanel for the graphic area and override paintComponent(Graphics g)

Interesting, so I guess that means it’s time to use “extends” and make my own class to use?

Yep!


public class MyFancyDrawing extends JPanel {

    public void paintComponent(Graphics g) {
        // your drawing code here
        g.drawWhateverYouWant(blah blah);
    }
}

...
MyFancyDrawing drawing = new MyFancyDrawing();
someFrame.getContentPane().add(drawing, BorderLayout.CENTER);

...

Very cool ;D I actually understand it too, gracias.