1

I haven't seen this stated explicitly anywhere, so I just want to confirm if my understanding is correct.

1.The default layout manager for a JFrame object is the BorderLayout and for any JComponent subclass object, it's FlowLayout.

2.In BorderLayout, if you simple add, without specifying the position (CENTER, SOUTH, etc), it adds at CENTER by default, which is why when you do this for two different objects, they are drawn on top of one another and only the most recent one is visible.

Are both these assumptions of mine correct?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 3
    See: http://stackoverflow.com/questions/30008010/using-an-anonymous-listener-object-inside-the-timer-class. You continue to ask lots of questions, but you have not yet "accepted" an answer on any question. – camickr May 03 '15 at 18:30
  • @camickr: Oh, I will. Do only JFrames have content panes or JPanels do as well? – Kane Williamson May 03 '15 at 18:37
  • `Oh, I will` still waiting... It doesn't take 9 minutes to revisit your old questions and start accepting answers. – camickr May 03 '15 at 18:47

1 Answers1

2
  1. In JavaDoc for javax.swing.JFrame: "The default content pane will have a BorderLayout manager set on it".
  2. In JavaDoc for java.awt.BorderLayout: " p2.add(new TextArea()); // Same as p.add(new TextArea(), BorderLayout.CENTER);"

All your assumptions is correct.

Lexover
  • 96
  • 1
  • 4