This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Layouts inside panel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Layouts inside panel" Watch "Layouts inside panel" New topic
Author

Layouts inside panel

Sandesh Jadhav
Greenhorn

Joined: Nov 01, 2008
Posts: 14
I am working on menu-based swing application. I am using CardLayout to display components on JFrame on clicking of the menu. I have used separate jpanel for each set of components to be diplayed inside JFrame. I would also need to layout the components dynamically on each panel on some event. For example, I will be displaying the List which is dynamically generated on clicking of the button inside the same panel. I might be having multiple dynamic components on same panel. So what approach should I take to layout the components inside the panel?

Thanks in advance


Cheers..
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> I might be having multiple dynamic components on same panel. So what approach should I take to layout the components inside the panel?

that's almost like asking , "I'm getting a new car, what color should I order?"

so, it's up to you - what are you trying to do?

if you want the dynamic panels to display one underneath the other,
in a scrollPane a GridLayout panel or a BoxLayout Panel might do
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Sandesh Jadhav wrote: So what approach should I take to layout the components inside the panel?


The UI design (as reflected by the layout) depends on you and your requirement.
In general you can dynamically add/remove from a container. Just make sure you call a revalidate and repaint to ensure your changes are reflected on the UI.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Layouts inside panel
 
Similar Threads
Gridbag layout problem, element comming in center
Resize Problem
Can I add a JPanel inside of another JPanel?
JPanel inside JFrame
JPanel validate()