I was wondering if there is a way, by clicking on the "X", to let the program perform some code before closing the JFrame. The setDefaultCloseOperation()
method takes only an integer.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
int i=JOptionPane.showConfirmDialog(null, "Seguro que quiere salir?");
if(i==0)
System.exit(0);//cierra aplicacion
}
});