我在做一个考试系统,有两个JFrame 一个是登陆窗体 LoginFrame , 一个是选题窗体 ChoiceFile ,在主程序里运行 LoginFrame ,我想在登录成功以后转到 ChoiceFile 窗体,同时关闭 LoginFrame 窗体。
现在我已经可以转到转到 ChoiceFile 窗体了,可是怎么关闭 LoginFrame 窗体呢?还请高手指点一下
现在我已经可以转到转到 ChoiceFile 窗体了,可是怎么关闭 LoginFrame 窗体呢?还请高手指点一下
private JButton jbutton = new JButton("打开选题窗口");
private ChoiceFrame choiceFrame;
public TestFrame(){
jbutton.addActionListener(this);
this.add(jbutton);
this.setBounds(200,200,500,400);
this.setVisible(true);
}
public static void main(String[] args){
new TestFrame();
}
public void actionPerformed(ActionEvent e){
choiceFrame = new ChoiceFrame();
this.dispose();
}
}class ChoiceFrame extends JFrame {
public ChoiceFrame(){
this.setTitle("选题");
this.setBounds(400,400,400,400);
this.setVisible(true);
}
}
new FrameStudent();
this.dispose();
this代表你当前的界面
FrameStudent代表你要打开的界面
既然你可以打开 那么你直接在打开你新的界面后 用当前对象调用 dispose方法关掉即可