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);
}
});
出来ますか?