Login without multiple windows

45 views Asked by At

I'm using Windows builder for create an application in Java. I create a frame with the login interface. What i want is that if the user insert correct information he will write something.

I don't want to open another JFrame I would like that the Login frame will be substitute with another one in order to have only one windows.

Could you tell me the correct object that I must use?

2

There are 2 answers

0
Narutachi On

you can close your current frame by using the command

this.dispose();

this will just close your current window. Just make sure you open the other window too.

JFrame frame = new [yourClassname]();

that should work just fine :)

0
AudioBubble On

The best options are using either a JOptionPane or a JDialog

JOptionPane works as a message box, and can be customized to your linking and usage. For example, if what you wanna show is a sucessfully logged in message, you could use:

JOptionPane.ShowMessageDialog(null, "Logged in sucessfully", "Logged in", JOptionPane.INFORMATION_MESSAGE);

You can find out about each parameter here. It's a pretty complete documentation of the JOptionPane.

JDialog is another time of window used by Window Builder, and is works as a window that cannot be switched, a classic modal dialog. While this screen is in usage you cannot acess others (as your JFrame), unless you command it to close. And to use this you can simply create it as you would with your Frame. It's modality is set by default.

From what I get of your message the first option would be the best alternative, but that decision's up to you.

I highly recommend you to look into some Window Builder documentation before you'd resort to Stack Overflow. This would be helpfull, it explains everything you need to know about the usage of Window Builder's windows and it's funcionalities.