frame.add(panel);
frame.pack();
frame.setResizable(false);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.addKeyListener(panel);
frame.setLocationByPlatform(true);
frame.setVisible(true);
class Test{
public static void main(String[] args) {
- DrawingWindow w = new DrawingWindow("Test!", 400, 400);
+ DrawingWindow w;
+
+ w = new DrawingWindow("Test!", 400, 400);
w.setColor("lawngreen");
for (int i = 0; i < 12; i++) {
w.drawTriangle(p, 125, p + i, 125 + i/2, p, 125 + i);
w.fillTriangle(p, 150, p + i, 150 + i/2, p, 150 + i);
}
+
+ w = new DrawingWindow("Test!", 800, 600);
+
+ w.setBgColor("red");
+ w.setColor("blue");
+ for (int i = 0; i < 10; i++) {
+ w.clearGraph();
+ for (int y = 0; y < w.height; y++) {
+ for (int x = 0; x < w.width; x++) {
+ w.drawPoint(x, y);
+ }
+ }
+ }
+ w.setColor("white");
+ for (int i = 0; i < 10; i++) {
+ w.clearGraph();
+ for (int y = 0; y < w.height; y++) {
+ for (int x = 0; x < w.width; x++) {
+ w.drawPoint(x, y);
+ }
+ w.sync();
+ }
+ }
+ w.closeGraph();
}
}
<h2>Modifications</h2>
<p><pre>
--- lun. 14 oct. 2014 13:33:48 +0200
+-- lun. 14 oct. 2014 14:09:22 +0200
* Ajout des méthodes setColor(int) et setBgColor(int).
* Liste de noms de couleurs plus complète.
+ * Ne termine l'application que lorsque la dernière fenêtre est fermée.
</pre>
</body>