开发者

How do i update swing application view from one screen to another?

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 s开发者_C百科creen? 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜