1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class MonApplication {
/*
* Pour exécuter une application, la classe servant de point d'entrée doit
* obligatoirement contenir une méthode ayant la signature public static
* void main(String[] args)
*/
public static void main(String[] args) {
System.out.println("MonApplication");
MaFenetre f = new MaFenetre();
f.afficher();
}
}
class MaFenetre {
JFrame mainFrame = null;
public MaFenetre() {
System.out.println("MaFenetre");
mainFrame = new JFrame();
mainFrame.setTitle("Mon application");
mainFrame.setSize(500, 500);
mainFrame.addWindowListener(new WindowAdapter() {
class MonAutreClass {
public void dessine() {
System.out.println("dessine");
}
}
public void windowClosing(WindowEvent ev) {
System.out.println("windowClosing");
System.exit(0);
}
});
}
public void afficher() {
mainFrame.setVisible(true);
System.out.println("afficher");
}
} |