mainFrame.addWindowListener(new WindowListener() {
@Override
public void windowClosing(WindowEvent e) {
if (JOptionPane.showConfirmDialog(mainFrame, "Are you sure you want to quit?", "Confirm exit.", JOptionPane.OK_OPTION, 0, new ImageIcon("")) != 0) {
return;
}
System.exit(-1);
}
@Override
public void windowOpened(WindowEvent e) {}
@Override
public void windowClosed(WindowEvent e) {}
@Override
public void windowIconified(WindowEvent e) {}
@Override
public void windowDeiconified(WindowEvent e) {}
@Override
public void windowActivated(WindowEvent e) {}
@Override
public void windowDeactivated(WindowEvent e) {}
});这是我的代码,有没有可能,因为我只使用windowClosing方法来删除所有其他的方法,无用的方法,以便它占用更少的空间?
示例
mainFrame.addWindowListener(new WindowListener() {
@Override
public void windowClosing(WindowEvent e) {
if (JOptionPane.showConfirmDialog(mainFrame, "Are you sure you want to quit?", "Confirm exit.", JOptionPane.OK_OPTION, 0, new ImageIcon("")) != 0) {
return;
}
System.exit(-1);
}
});有可能吗?
发布于 2012-11-03 16:46:30
WindowListener有一个名为WindowAdapter的缺省实现,它允许您覆盖真正想要使用的方法
https://stackoverflow.com/questions/13207519
复制相似问题