File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Positioning JPanels in a JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Positioning JPanels in a JPanel" Watch "Positioning JPanels in a JPanel" New topic

Positioning JPanels in a JPanel

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
Is there a way I can create 4 JPanels inside an outer JPanel, however
initially only the top JPanel is visible. Then when an event occurs the others appear 1 directly below the other with no gaps?

Daniel Mayer
Ranch Hand

Joined: Sep 09, 2004
Posts: 103
Just put the panels in the appropriate layout, for example a BoxLayout, and hide() the three lower panels initially. Call show() on them once you want them to be visible.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link:
subject: Positioning JPanels in a JPanel
It's not a secret anymore!