diff options
Diffstat (limited to 'ws2015/eip/blaetter/04')
-rw-r--r-- | ws2015/eip/blaetter/04/GraphicsWindow.java | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/ws2015/eip/blaetter/04/GraphicsWindow.java b/ws2015/eip/blaetter/04/GraphicsWindow.java index b92fdaf..2bb652d 100644 --- a/ws2015/eip/blaetter/04/GraphicsWindow.java +++ b/ws2015/eip/blaetter/04/GraphicsWindow.java | |||
@@ -1,3 +1,6 @@ | |||
1 | package gameoflifetest; | ||
2 | |||
3 | import java.awt.*; | ||
1 | import java.util.ArrayList; | 4 | import java.util.ArrayList; |
2 | import javax.swing.JFrame; | 5 | import javax.swing.JFrame; |
3 | import javax.swing.JPanel; | 6 | import javax.swing.JPanel; |
@@ -9,16 +12,8 @@ import java.awt.event.MouseAdapter; | |||
9 | import java.awt.event.WindowAdapter; | 12 | import java.awt.event.WindowAdapter; |
10 | import java.awt.event.WindowEvent; | 13 | import java.awt.event.WindowEvent; |
11 | import java.awt.event.MouseEvent; | 14 | import java.awt.event.MouseEvent; |
12 | import java.awt.Graphics; | ||
13 | import java.awt.Graphics2D; | ||
14 | import java.awt.Shape; | ||
15 | import java.awt.geom.RectangularShape; | 15 | import java.awt.geom.RectangularShape; |
16 | import java.awt.geom.GeneralPath; | 16 | import java.awt.geom.GeneralPath; |
17 | import java.awt.Point; | ||
18 | import java.awt.Label; | ||
19 | import java.awt.Font; | ||
20 | import java.awt.Color; | ||
21 | import java.awt.Rectangle; | ||
22 | 17 | ||
23 | /** | 18 | /** |
24 | Eine Klasse zu pädagogischen Zwecken. | 19 | Eine Klasse zu pädagogischen Zwecken. |
@@ -26,7 +21,7 @@ import java.awt.Rectangle; | |||
26 | mittels Mausklicks, das Zeichnen einfacher | 21 | mittels Mausklicks, das Zeichnen einfacher |
27 | 2D Objekte (java.awt.Shape), sowie die | 22 | 2D Objekte (java.awt.Shape), sowie die |
28 | Ausgabe von Texten in einer Statuszeile. | 23 | Ausgabe von Texten in einer Statuszeile. |
29 | @version 3.042 | 24 | @version 3.043 |
30 | @author Martin Hofmann und die EiP-Teams verschiedener Jahre | 25 | @author Martin Hofmann und die EiP-Teams verschiedener Jahre |
31 | */ | 26 | */ |
32 | 27 | ||
@@ -57,13 +52,15 @@ public class GraphicsWindow { | |||
57 | @param height Höhe des Fensters | 52 | @param height Höhe des Fensters |
58 | */ | 53 | */ |
59 | public GraphicsWindow(int width, int height) { | 54 | public GraphicsWindow(int width, int height) { |
60 | this.width = width; | 55 | this.width = width; |
61 | this.height = height; | 56 | this.height = height; |
62 | dasFenster = new JFrame(); | 57 | dasFenster = new JFrame(); |
63 | dasFenster.setTitle("Grafikfenster " + ++fensterNr); | 58 | dasFenster.setTitle("Grafikfenster " + ++fensterNr); |
64 | fensterZahl++; | 59 | fensterZahl++; |
65 | dasFenster.setLocationByPlatform(true); | 60 | dasFenster.setLocationByPlatform(true); |
66 | dasFenster.setSize(width,height+50); | 61 | dasFenster.setSize(width,height+50); |
62 | dasFenster.getContentPane().setPreferredSize(new Dimension(width, height+50)); | ||
63 | dasFenster.pack(); | ||
67 | dasFenster.addWindowListener(new WindowAdapter(){ | 64 | dasFenster.addWindowListener(new WindowAdapter(){ |
68 | public void windowClosing(WindowEvent e) { | 65 | public void windowClosing(WindowEvent e) { |
69 | dasFenster.dispose(); // nicht gleich alle Fenster abschiessen | 66 | dasFenster.dispose(); // nicht gleich alle Fenster abschiessen |
@@ -74,7 +71,6 @@ public class GraphicsWindow { | |||
74 | label = new Label("Statuszeile..."); | 71 | label = new Label("Statuszeile..."); |
75 | label.setFont(new Font("Helvetica", Font.PLAIN, 12)); | 72 | label.setFont(new Font("Helvetica", Font.PLAIN, 12)); |
76 | dasFenster.getContentPane().add(label,"North" ); | 73 | dasFenster.getContentPane().add(label,"North" ); |
77 | |||
78 | panel = new GraphicsWindowPanel(); | 74 | panel = new GraphicsWindowPanel(); |
79 | //panel.setBackground(Color.cyan); | 75 | //panel.setBackground(Color.cyan); |
80 | panel.addCommand(new SetColor(activeColor)); | 76 | panel.addCommand(new SetColor(activeColor)); |
@@ -243,11 +239,11 @@ public class GraphicsWindow { | |||
243 | 239 | ||
244 | /** Löscht das Bild */ | 240 | /** Löscht das Bild */ |
245 | public void clear() { | 241 | public void clear() { |
246 | Color oldActive = activeColor; | 242 | // Color oldActive = activeColor; |
247 | panel.clearAll(); | 243 | panel.clearAll(); |
248 | this.switchToBackgroundColor(); | 244 | // this.switchToBackgroundColor(); |
249 | fill(new Rectangle(0,0,width,height)); | 245 | // fill(new Rectangle(0,0,width,height)); |
250 | setColor(oldActive); | 246 | // setColor(oldActive); |
251 | } | 247 | } |
252 | 248 | ||
253 | public void killIn(int secs) { | 249 | public void killIn(int secs) { |