Java窗体程序问题,关于父窗口与子窗口的关闭问题

2024-12-14 01:26:55
推荐回答(1个)
回答1:

jf.addWindowListener(new WindowListener(){

@Override
public void windowActivated(WindowEvent e) {
}

@Override
public void windowClosed(WindowEvent e) {
}

@Override
public void windowClosing(WindowEvent e) {
Window window =e.getWindow();
window.dispose();
}

@Override
public void windowDeactivated(WindowEvent e) {
}

@Override
public void windowDeiconified(WindowEvent e) {
}

@Override
public void windowIconified(WindowEvent e) {
}

@Override
public void windowOpened(WindowEvent e) {
}});
jf是子窗体。加上这句就行了。