18

我有一JFrame堂课,它是在 Netbeans 的设计部​​分制作的。我正在尝试制作一个登录按钮来关闭当前框架并打开另一个框架,无论如何我可以这样做吗?

我努力了:

JFrame frame = new JFrame(); 

但我希望它在设计部分是可编辑的!

4

4 回答 4

23

双击 NETBEANS 中的登录按钮或在单击事件上添加事件侦听器 (ActionListener)

btnLogin.addActionListener(new ActionListener() 
{
    public void actionPerformed(ActionEvent e) {
        this.setVisible(false);
        new FrmMain().setVisible(true); // Main Form to show after the Login Form..
    }
});
于 2013-07-14T06:57:22.050 回答
7
new SecondForm().setVisible(true);

您可以使用setVisible(false)dispose()方法使当前表单消失。

于 2015-01-16T10:17:06.350 回答
6

此链接适用于我:视频

之前发布的答案直到第二次点击才对我有用

所以我所做的是直接调用:

        new NewForm().setVisible(true);

        this.dispose();//to close the current jframe
于 2014-12-04T13:10:19.660 回答
1
JFrame.setVisible(true);

您可以使用setVisible(false)dispose()方法使当前表单消失。

于 2015-08-01T20:22:31.587 回答