How do i update swing application view from one screen to another? – Education Career Blog

I am a beginner in java swing.
I have just created my first login screen using netbean.
I like to ask after my actionPerformed if say login successfully. How do i actually go to the next screen? As in coding wise how should i code or netbeans got something build in for this

,

You should have a new class that extends Jframe called something appropriate (MainWindow maybe) that gets created when the user enters the correct password, so probably in the eventListener code for the button

if (usernameAndPasswordCorrect()) {
    loginWindow.setVisible(false);
    loginWindow.dispose();
    MainWindow w = new MainWindow();
    w.setVisible(true);
}
else {
    JOptionPane.showMessageDialog(loginWindow, "Incorrect login information. Try again.");
}

Or something like that.

Leave a Comment