I have five JFrame
s in my program. I want those to be in a CardLayout
.
Suppose A
is the main frame and B,C,D,E
are sub-frames.
Now, I want to put four buttons in A
which will open the sub-frames individually. All the sub-frames will have a 'Back' button to go back to main frame. How do I do this in CardLayout
? Let me know if there's any other layout to do so.
Asked
Active
Viewed 180 times
1

Andrew Thompson
- 168,117
- 40
- 217
- 433

Rifat Bin Reza
- 2,601
- 2
- 14
- 29
1 Answers
2
No, a JFrame
is a top-level container. Presumably, each of your existing frames sets or adds a container to the content pane, so you can add those containers to the CardLayout
. Several examples are shown here. Also consider a JToolBar
, seen here, for your navigation panel.