问题描述:我做了一个JFrame的窗体,一开始我在上面放了一个面板.在面板上有一个按钮,我想在我点这个按钮的时候把这个面板从窗体中
移去,接着我又NEW一个PANEL的子类(stuWindow),再加到这个窗体上,但为什么不会显示呢?按钮的代码:
StuWindow stuWindow=new StuWindow(new Student());//新的面板
this.getContentPane().remove(login);//login为一开始的面板
this.update(this.getGraphics());
stuWindow.setVisible(true);
stuWindow.setBounds(0,0,400,500);
this.getContentPane().add(stuWindow);
fileMenu.setEnabled(true);
helpMenu.setEnabled(true);
this.update(this.getGraphics());我按下按钮后为什么窗体上不显示新的面板 stuWindow?请高手指点下?
移去,接着我又NEW一个PANEL的子类(stuWindow),再加到这个窗体上,但为什么不会显示呢?按钮的代码:
StuWindow stuWindow=new StuWindow(new Student());//新的面板
this.getContentPane().remove(login);//login为一开始的面板
this.update(this.getGraphics());
stuWindow.setVisible(true);
stuWindow.setBounds(0,0,400,500);
this.getContentPane().add(stuWindow);
fileMenu.setEnabled(true);
helpMenu.setEnabled(true);
this.update(this.getGraphics());我按下按钮后为什么窗体上不显示新的面板 stuWindow?请高手指点下?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货