我的程序以JFrame中带有文本字段的图片开始。当用户输入"start"时,我希望它关闭图片JFrame并打开另一个包含主程序的JFrame。我尝试在图片窗口中使用
processEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
但它会关闭所有窗口。
我的程序以JFrame中带有文本字段的图片开始。当用户输入"start"时,我希望它关闭图片JFrame并打开另一个包含主程序的JFrame。我尝试在图片窗口中使用
processEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
但它会关闭所有窗口。
这是我想到的在关闭另一个JFrame时打开新JFrame的方法:
JFrame CreateAccountGUI = new JFrame();
CreateAccountGUI.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
CreateAccountGUI.setSize(800, 600);
CreateAccountGUI.setLocationRelativeTo(null);
CreateAccountGUI.setVisible(true);
this.setVisible(false);
if(username.equals("gaffar")&&password.equals("12345"))
{
label.setText("Be ready to continue");
//Start of 2nd jframe
NewJFrame1 n=new NewJFrame1();
n.setVisible(true);
//Stop code for ist jframe
NewJFrame m=new NewJFrame();
m.setVisible(false);
dispose();
}