【发布时间】:2013-12-14 13:02:58
【问题描述】:
我不知道为什么我的代码不能正常工作。当我试图打开 window(BazaDanych) 时,只出现 window2(ZmienBaze),我不知道为什么。窗口(BazaDanych)根本没有打开。也许你能帮帮我。
class GlowneMenu extends JFrame implements ActionListener
{
public GlowneMenu()
{
setTitle("Menu");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
...<not important just Menu stuff>
JMenu info = new JMenu("Info");
...<not important just JMenu and label stuff>
}
public void actionPerformed(ActionEvent e){
new BazaDanych().setVisible(true);
this.dispose();
new ZmienBaza().setVisible(true);
this.dispose();
}
public static void main( String[] args){new GlowneMenu().setVisible(true);}
}
class BazaDanych extends JFrame{
public BazaDanych()
{
setTitle("Baza danych");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocation(400,100);
...<not importent just this window stuff>
}
}
class ZmienBaza extends JFrame{
public ZmienBaza()
{
setTitle("Zmiana Bazy");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocation(400,100);
...<not importent just this window stuff>
}
}
我发现当我删除这个 :* 我的代码将正常工作,但只适用于一个窗口。如何通过这些方式添加更多窗口?
*new ZmienBaza().setVisible(true);
this.dispose();
【问题讨论】:
-
1) 为了尽快获得更好的帮助,请发帖 SSCCE。 2) 见The Use of Multiple JFrames, Good/Bad Practice?