/**
* Fenêtre
* - La classe principale implante le listener.
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 1.41
*/
import java.awt.*;
import java.awt.event.*;
public class Fenetre14 implements WindowListener {
/* Interface WindowListener */
public void windowActivated (WindowEvent e) {}
public void windowClosed (WindowEvent e) {System.exit(0);}
public void windowClosing (WindowEvent e) {((Frame)e.getSource()).dispose();}
public void windowDeactivated (WindowEvent e) {}
public void windowDeiconified (WindowEvent e) {}
public void windowIconified (WindowEvent e) {}
public void windowOpened (WindowEvent e) {}
public static void main (String[] args) {
Frame fen = new Frame("Fenêtre - V1.4");
fen.addWindowListener(new Fenetre14());
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre14
/**
* Fenêtre
* - La classe principale EST la fenêtre et implante le listener.
* - La fenêtre est donc son propre listener.
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 1.51
*/
import java.awt.*;
import java.awt.event.*;
public class Fenetre15 extends Frame implements WindowListener {
/* Constructeur */
public Fenetre15 (String titre) {super(titre);}
/* Interface WindowListener */
public void windowActivated (WindowEvent e) {}
public void windowClosed (WindowEvent e) {System.exit(0);}
public void windowClosing (WindowEvent e) {((Frame)e.getSource()).dispose();}
public void windowDeactivated (WindowEvent e) {}
public void windowDeiconified (WindowEvent e) {}
public void windowIconified (WindowEvent e) {}
public void windowOpened (WindowEvent e) {}
public static void main (String[] args) {
Fenetre15 fen = new Fenetre15("Fenêtre - V1.5");
fen.addWindowListener(fen);
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre15
/**
* Adaptateur de WindowListener
* - Permet de déclarer des extensions utilisables comme listeners. Les
* extensions devront seulement redéfinir les méthodes qui les intéressent.
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 2.0
*/
import java.awt.event.*;
public class MyWindowAdapter implements WindowListener {
public void windowActivated (WindowEvent e) {}
public void windowClosed (WindowEvent e) {}
public void windowClosing (WindowEvent e) {}
public void windowDeactivated (WindowEvent e) {}
public void windowDeiconified (WindowEvent e) {}
public void windowIconified (WindowEvent e) {}
public void windowOpened (WindowEvent e) {}
}// MyWindowAdapter
/**
* Fenêtre
* - Le listener chargé de gérer l'événement de fermeture est
* une classe membre dérivée de l'adapter
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 2.11
*/
import java.awt.*;
import java.awt.event.*;
public class Fenetre21 {
private static class MyWindowListener extends MyWindowAdapter {
public void windowClosed (WindowEvent e) {System.exit(0);}
public void windowClosing (WindowEvent e) {((Frame)e.getSource()).dispose();}
}// MyWindowListener
public static void main (String[] args) {
Frame fen = new Frame("Fenêtre - V2.1");
fen.addWindowListener(new MyWindowListener());
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre21