I have about 3 frames in my java swing application. What it the correct way how to handle with these frames? I mean some pattern or something else. Now I have always one class which represent frame and one class for panel which is main in this frame. Now I have defined frames as static variable and when I wanna hide them I call
classname.frameName.setVisible(false);
is this the correct solution?
Besides the (excellent) suggestions of a
CardLayoutorJFramewith multipleJDialoginstances, 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.).JPanelin a nested layout.There are probably more..
Of course, as Adamski pointed out, there are some further quirks to consider..
Possibly combine them as sub-menus.