當使用的Java GUI打開一個新的窗口,我要關閉舊的或只是重定向舊的窗口到新我想如何在java中關閉舊窗口?
setVisible(false)
,但沒有奏效。
整個的ActionListener代碼:當你的新窗口被激活或者打開使用Dispose()方法來終止舊的窗口
public class Domainevent implements ActionListener{
public void actionPerformed (ActionEvent event){
GUI gg = new GUI();
DomainGUI ee = new DomainGUI();
gg.dispose();
ee.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ee.setTitle("Forbidden Domains");
ee.setSize(700,500);
ee.setLocation(350,100);
ee.setResizable(false);
}
}
你可以發佈代碼嗎? – 2013-04-26 18:54:21
我編輯了問題併發布了代碼 – 2013-04-26 19:03:30
GUI中的代碼是什麼?你爲此JForm第一次setVisible(true)嗎? – 2013-04-26 19:15:22