FermetureFenetre.java
691 Bytes
package tp2.evenements;
import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class FermetureFenetre extends WindowAdapter {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosing(e);
System.out.println("Fenetre en cours de fermeture");
System.exit(0);
}
public static void main(String[] args) {
JFrame win = new JFrame();
win.addWindowListener(new FermetureFenetre());
win.setLocationRelativeTo(null);
win.setResizable(false);
win.pack();
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.setVisible(true);
}
}