質問編集履歴
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,6 +30,8 @@
|
|
30
30
|
|
31
31
|
}*/
|
32
32
|
|
33
|
+
Color cuurentColor = Color.black;
|
34
|
+
|
33
35
|
|
34
36
|
|
35
37
|
public Draw(){
|
@@ -50,6 +52,14 @@
|
|
50
52
|
|
51
53
|
|
52
54
|
|
55
|
+
public void setColor(Color newColor){
|
56
|
+
|
57
|
+
currrentColor = new Color;
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
53
63
|
class SampleWindowListener extends WindowAdapter{
|
54
64
|
|
55
65
|
public void windowClosing(WindowEvent e){
|
@@ -80,6 +90,8 @@
|
|
80
90
|
|
81
91
|
cy = e.getY();
|
82
92
|
|
93
|
+
g.setColor(currentColor);
|
94
|
+
|
83
95
|
g.drawLine(x,y,cx,cy);
|
84
96
|
|
85
97
|
x = cx;
|
@@ -204,33 +216,33 @@
|
|
204
216
|
|
205
217
|
if(e.getSource()==Whitebt){
|
206
218
|
|
207
|
-
|
219
|
+
drawarea.setColor(Color.white);
|
208
220
|
|
209
221
|
}else if(e.getSource()==Blackbt){
|
210
222
|
|
211
|
-
|
223
|
+
drawarea.setColor(Color.black);
|
212
224
|
|
213
225
|
}else if(e.getSource()==Redbt){
|
214
226
|
|
215
|
-
|
227
|
+
drawarea.setColor(Color.red);
|
216
228
|
|
217
229
|
}else if(e.getSource()==Bluebt){
|
218
230
|
|
219
|
-
|
231
|
+
drawarea.setColor(Color.blue);
|
220
232
|
|
221
233
|
}else if(e.getSource()==Greenbt){
|
222
234
|
|
223
|
-
|
235
|
+
drawarea.setColor(Color.green);
|
224
236
|
|
225
237
|
}else if(e.getSource()==Clearbt){
|
226
238
|
|
227
239
|
Graphics g = getGraphics();
|
228
240
|
|
229
|
-
|
241
|
+
drawarea.setColor(Color.white);
|
230
242
|
|
231
243
|
g.fillRect(0,0,getSize().width,getSize().height);
|
232
244
|
|
233
|
-
|
245
|
+
drawarea.setColor(Color.black);
|
234
246
|
|
235
247
|
repaint();
|
236
248
|
|