소스안에 다음과 같은 코드를 추가한다.
class MyFrame extends JFrame
{
.....
.....
.....
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
....
....
....
}
[또다른 방법] 다음과 코드를 추가한다.
/** Overridden so we can exit when window is closed */
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if(e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
2007/11/05 21:26