[英]How to make a JFrame button open another JFrame class in Netbeans?
I have a JFrame
class and it was made in the design section on Netbeans. 我有一个JFrame
类,它是在Netbeans的设计部分制作的。 I am trying to make a log in button that takes closes the current frame and opens another, is there anyway I can do that? 我正在尝试创建一个登录按钮,关闭当前帧并打开另一个,无论如何我能做到吗?
I have tried: 我试过了:
JFrame frame = new JFrame();
But I want it to be editable in the design section! 但我希望它在设计部分可以编辑!
Double Click the Login Button in the NETBEANS or add the Event Listener on Click Event (ActionListener) 双击NETBEANS中的登录按钮或在Click事件上添加事件监听器(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()
方法来消除当前表单。
JFrame.setVisible(true);
您可以使用setVisible(false)
或dispose()
方法来消除当前表单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.