/** * Fenêtre infermable * * @author Peter DAEHNE - HEG

/**
* Fenêtre infermable
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 0.01
*/
import java.awt.*;
public class Fenetre00 {
public static void main (String[] args) {
/* Une Frame est initialement invisible */
Frame fen = new Frame("Fenêtre (infermable) - V0.0");
fen.setSize(500, 400); /* Fixe sa dimension */
fen.setVisible(true); /* Rend la fenêtre visible */
}// main
}// Fenetre00
/**
* Fenêtre infermable
* - La classe principale EST la fenêtre
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 0.11
*/
import java.awt.*;
public class Fenetre01 extends Frame {
/* Constructeur */
public Fenetre01 (String titre) {super(titre);}
public static void main (String[] args) {
Fenetre01 fen = new Fenetre01("Fenêtre (infermable) - V0.1");
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre01
/**
* Fenêtre
* - Le listener chargé de gérer l'événement de fermeture est
* une classe publique (ou package)
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 1.01
*/
import java.awt.*;
public class Fenetre10 {
public static void main (String[] args) {
Frame fen = new Frame("Fenêtre - V1.0");
fen.addWindowListener(new MyWindowListener());
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre10
/**
* Listener chargé de gérer l'événement de fermeture d'une fenêtre
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 1.0
*/
import java.awt.*;
import java.awt.event.*;
public class MyWindowListener implements 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) {}
}// MyWindowListener
/**
* Fenêtre
* - Le listener chargé de gérer l'événement de fermeture est
* une classe membre
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 1.11
*/
import java.awt.*;
import java.awt.event.*;
public class Fenetre11 {
private static class MyWindowListener implements 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) {}
}// MyWindowListener
public static void main (String[] args) {
Frame fen = new Frame("Fenêtre - V1.1");
fen.addWindowListener(new MyWindowListener());
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre11
/**
* Fenêtre
* - Le listener chargé de gérer l'événement de fermeture est
* une classe locale (à la méthode qui crée la fenêtre).
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 1.21
*/
import java.awt.*;
import java.awt.event.*;
public class Fenetre12 {
public static void main (String[] args) {
class MyWindowListener implements 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) {}
}// MyWindowListener
Frame fen = new Frame("Fenêtre - V1.2");
fen.addWindowListener(new MyWindowListener());
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre12
/**
* Fenêtre
* - Le listener chargé de gérer l'événement de fermeture est
* une classe (locale) anonyme.
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 1.31
*/
import java.awt.*;
import java.awt.event.*;
public class Fenetre13 {
public static void main (String[] args) {
Frame fen = new Frame("Fenêtre - V1.3");
fen.addWindowListener(new 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) {}
});
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre13
/**
* 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
/**
* Fenêtre
* - Le listener chargé de gérer l'événement de fermeture est
* une classe membre dérivée de l'adapter de la bibliothèque.
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 3.11
*/
import java.awt.*;
import java.awt.event.*;
public class Fenetre31 {
private static class MyWindowListener extends WindowAdapter {
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 - V3.1");
fen.addWindowListener(new MyWindowListener());
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre31
/**
* Fenêtre
* - Le listener chargé de gérer l'événement de fermeture est
* une classe (locale) anonyme dérivant de WindowAdapter.
*
* @author Peter DAEHNE - HEG-Genève
* @version Version 3.31
*/
import java.awt.*;
import java.awt.event.*;
public class Fenetre33 {
public static void main (String[] args) {
Frame fen = new Frame("Fenêtre - V3.3");
fen.addWindowListener(new WindowAdapter() {
public void windowClosed (WindowEvent e) {System.exit(0);}
public void windowClosing (WindowEvent e) {((Frame)e.getSource()).dispose();}
});
fen.setSize(500, 400);
fen.setVisible(true);
}// main
}// Fenetre33
1 / 4 100%
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !