java - Run function on JFrame close -
void terminate() {} protected jframe frame = new jframe();
how can frame
run terminate function when press close button?
edit: tried run this, reason doesn't print test (however, program closes). have idea problem?
frame.addwindowlistener(new windowadapter() { public void windowclosing(windowevent e) { system.out.println("test"); frame.dispose(); } });
you can use addwindowlistener:
frame.addwindowlistener(new windowadapter() { public void windowclosing(windowevent e) { ... //call terminate ... } });
see void windowclosing(windowevent e) , class windowadapter too.
Comments
Post a Comment