Besides the (excellent) suggestions of a CardLayout
or JFrame
with multiple JDialog
instances, here are some other strategies which might work singly or in combination, to collapse a variety of content panes into a single frame.
JDesktopPane
/JInternalFames
(Tut.).
JSplitPane
(Tut.).
JTabbedPane
(Tut.).
JLayeredPane
, if you're feeling brave (Tut.).
JToolBar
- floatable if needed (Tut.).
- Different constraints of a
JPanel
in a nested layout.
There are probably more..
Of course, as Adamski pointed out, there are some further quirks to consider..
What if each frame has JMenuBars or JMenus?
Possibly combine them as sub-menus.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…