0
我试图从另一个类ABC的名为testView的类中显示一个窗口。窗口包含一个按钮。我想关闭该按钮上的窗口。我如何关闭它?关闭按钮上的容器单击
public class testView extends JFrame {
protected JButton closeButton = new JButton("Close");
testView(){
this.setSize(1000,700);
this.setTitle("Test");
Container window = getContentPane();
window.setLayout(new FlowLayout());
this.setResizable(false);
window.add(closeButton);
}
}
public class ABC{
public static void main(String[] args) {
testView View = new testView();
View.setVisible(true);
}
}
从另一个类ABC显示窗口。如何关闭按钮单击窗口?
只需使用Dispose()方法关闭它 –