java - Make Jbutton fully mimic "X" button -


i developing application uses full screen , jbutton in top right should act close "x" button application. thing is, make mimic actual "x" button.

i'll explain, program has implemented ways make closing of application different things via settings menu (close/minimize/hide tray) use setdefaultcloseoperation , not work jbutton set up, because neither

system.exit(0); 

or

frame.dispose(); 

take consideration setdefaultcloseoperation, close frame no matter setdefaultcloseoperation tells do.

is there way create button follows rules of setdefaultcloseoperation or have change code work around that?

you can create jbutton event, , event, call system.exit(0); function.

this example:

jbutton exit = new jbutton("exit"); exit.addactionlistener(new actionlistener() {      @override     public void actionperformed(actionevent e) {         // want before exit program         system.exit(0);     // exit program     //  frame.dispose();    // "hide" jframe     } }); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -