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?
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.