codice:
import javax.swing.*;
import java.awt.event.*;
public class detectClosing extends JFrame implements WindowListener {
public void windowActivated (WindowEvent we) {
}
public void windowClosed (WindowEvent we) {
}
public void windowClosing (WindowEvent we) {
int i = JOptionPane.showConfirmDialog(this, "Vuoi uscire?", "Exit Panel", JOptionPane.YES_NO_OPTION);
if (i==0) {
System.exit(0);
}
}
public void windowDeactivated (WindowEvent we) {
}
public void windowDeiconified (WindowEvent we) {
}
public void windowIconified (WindowEvent we) {
}
public void windowOpened (WindowEvent we) {
}
public detectClosing() {
super("Prova a chiudermi");
this.setSize(400, 300);
this.setVisible(true);
this.addWindowListener(this);
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}
public static void main (String[] arg) {
detectClosing dc = new detectClosing();
}
}
Pasqua tutto l'anno