我有以下代码:
public AudioDialog() {
this.addWindowListener(new WindowListener() {
public void windowActivated(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
System.out.println("deactivated");
dispose();
}
public void windowDeiconified(WindowEvent e) {
}
public void windowIconified(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
});
}
当JDialog失去焦点时,windowDeactivated在Windows下正确执行,但在Mac下没有任何事情发生。
有人可以告诉我我做错了吗?