0

I have this JPanel (a) with BoxLayout.

When I add another JPanel (b) to it, with setPreferredSize() and setBackground(), it gets drawn nicely on (a). However, if I setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS) on (b), it doesn't get drawn at all. Or added, I cannot be sure.

If I use other layout manager (e.g. BorderLayout), it appears again.

Anybody care to explain?

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
Karlovsky120
  • 6,212
  • 8
  • 41
  • 94
  • What is the class where you set the new BoxLayout(this, ...) ? – Dan D. Aug 26 '12 at 20:53
  • (b) is actually a class that extends JPanel, but it doesn't really do anything except written above. Comenting out setlayout command triggers the change (see me - don't see me) BTW, It's the boxlayout, if I set it to e.g. borderlayout, it works... – Karlovsky120 Aug 26 '12 at 21:00
  • 1
    Please edit your question to include an [sscce](http://sscce.org/) that exhibits the problem you describe. – trashgod Aug 27 '12 at 03:03

1 Answers1

0

I seemes that other components (with null layout) added to same parent got in the way. Setting a layout different from null to all the children of parent component fixes the issue, and keeps the layout to look as if they were all null layout...

Karlovsky120
  • 6,212
  • 8
  • 41
  • 94