我有一JFrame
堂课,它是在 Netbeans 的设计部分制作的。我正在尝试制作一个登录按钮来关闭当前框架并打开另一个框架,无论如何我可以这样做吗?
我努力了:
JFrame frame = new JFrame();
但我希望它在设计部分是可编辑的!
双击 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..
}
});
new SecondForm().setVisible(true);
您可以使用setVisible(false)
或dispose()
方法使当前表单消失。
此链接适用于我:视频
之前发布的答案直到第二次点击才对我有用
所以我所做的是直接调用:
new NewForm().setVisible(true);
this.dispose();//to close the current jframe
JFrame.setVisible(true);
您可以使用setVisible(false)
或dispose()
方法使当前表单消失。