You can use JInternalFrame
to manage your sign-in screens.
A very simple example. Consider that you have your main screen, MainFrame
, which has a menu, something like this:
Theshortcodeneededtocreatethisscreenwouldlooksomethinglikethis:
publicclassMainFrameextendsJFrame{privatestaticfinallongserialVersionUID=-4985498392168006224L;privatefinalJDesktopPanedesktop=newJDesktopPane();publicMainFrame(){super("Tela Principal");
final int inset = 50;
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
final Dimension dimension = new Dimension(screenSize.width / 3, screenSize.height / 2);
this.setBounds(inset, inset, dimension.width - inset * 2, dimension.height - inset * 2);
this.setContentPane(desktop);
this.setJMenuBar(this.createMenuBar());
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
}
// esse é o cara chamado ao acessarmos o menu, ou no seu caso, clicar no botão :)
protected void createFrame() {
final UsuarioInternalFrame frame = new UsuarioInternalFrame();
frame.setVisible(true);
desktop.add(frame);
try {
frame.setSelected(true);
} catch (final PropertyVetoException e) {
// trate a exceção conforme sua necessidade
}
}
}
Note: As the intent is not to present the basics of swing, just use JInternalFrame
, I will not put how to create the menu, open the main screen, etc. =)
When we go to the Registrations menu - > Users , we'd display a JInternalFrame
:
Theclickeventonthemenu,button,etc.,basicallycreatestheinternalframeweneed,thecreateFrame
methodofourmainscreen.ThecodeforUsuarioInternalFrame
issimple,somethinglikethis:
publicclassUsuarioInternalFrameextendsJInternalFrame{privatestaticfinallongserialVersionUID=-619850559630326110L;publicUsuarioInternalFrame(){super("Usuários", true, true, true, true);
this.setSize(500, 300);
this.setLocation(30, 30);
}
}
So you can have multiple internal frames , you can maximize them:
Minimizeit:
Finally,customizeaccordingtoyourneeds,asIsaid,tomakethesizeofitonlyinthegrayareaofyourCorelexample,termonthesidesofthemenus,atree,etc.Thereareseveralwaystodoit.
Thisisjustabasicexampleofhowyoucanuse JInternalFrame
, and the example can be customized to suit your needs. In certain cases you can use JPanel
, but if I understand your problem, internal frames will give you more flexibility if you do not have to customize a JPanel
a lot.