events - close java frame using code -


possible duplicate:
how programmatically close jframe

i developing java gui using jframe. want close gui frame , dispose off through code. have implemented :

topframe.addwindowlistener(new windowlistener()         {             public void windowclosing(windowevent e)             {                 emsclient.close();             }             public void windowopened(windowevent e) {             }             public void windowclosed(windowevent e) {             }             public void windowiconified(windowevent e) {             }             public void windowdeiconified(windowevent e) {             }             public void windowactivated(windowevent e) {             }             public void windowdeactivated(windowevent e) {             }         });` 

how can invoke windowclosing event?? or there other way?

you need this:

yourframe.setdefaultcloseoperation(jframe.exit_on_close); 

you can add line in constructor(dont forget it).


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -