質問編集履歴
1
ご指摘によりソースの縮小、全文を載せました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -17,12 +17,47 @@
|
|
17
17
|
import java.applet.*;
|
18
18
|
import java.awt.*;
|
19
19
|
|
20
|
-
public class
|
20
|
+
public class clock4 extends Applet implements Runnable {
|
21
21
|
Dimension d;
|
22
22
|
Thread kicker = null;
|
23
|
+
Image offs;
|
24
|
+
Graphics grf;
|
25
|
+
int r;
|
26
|
+
int yohaku;
|
27
|
+
int Time4 = 999;
|
28
|
+
int kirikae = 0;
|
23
29
|
|
30
|
+
public void init() {
|
24
|
-
|
31
|
+
d=getSize();
|
32
|
+
String param = getParameter("yohaku");
|
33
|
+
yohaku = (param != null)? Integer.parseInt(param):5;
|
34
|
+
r=(d.width<d.height)? (int)(d.width-yohaku*2)/2 : (int)(d.height-yohaku*2)/2;
|
25
35
|
|
36
|
+
offs=createImage(d.width, d.height);
|
37
|
+
grf=offs.getGraphics();
|
38
|
+
}
|
39
|
+
|
40
|
+
public void run() {
|
41
|
+
Thread.currentThread().setPriority(Thread.NORM_PRIORITY-3);
|
42
|
+
while(kicker != null) {
|
43
|
+
repaint();
|
44
|
+
try {
|
45
|
+
Thread.sleep(100);
|
46
|
+
} catch(InterruptedException e) {}
|
47
|
+
}
|
48
|
+
// kicker=null;
|
49
|
+
}
|
50
|
+
|
51
|
+
public void update(Graphics g){
|
52
|
+
paint(g);
|
53
|
+
}
|
54
|
+
|
55
|
+
public void paint(Graphics g) {
|
56
|
+
grf.setColor(Color.white);
|
57
|
+
grf.fillRect(0, 0, r * 2 + yohaku*2, r * 2 + yohaku*2);
|
58
|
+
|
59
|
+
int x1, y1, x, y;
|
60
|
+
|
26
61
|
Calendar Now = Calendar.getInstance(TimeZone.getDefault());
|
27
62
|
|
28
63
|
int Time1 = (int) (Now.get(Calendar.HOUR_OF_DAY) * 30 + Now.get(Calendar.MINUTE) * 0.5);
|
@@ -30,4 +65,29 @@
|
|
30
65
|
|
31
66
|
int Time2 = (int) (Now.get(Calendar.MINUTE) * 6 + Now.get(Calendar.SECOND) * 0.1);
|
32
67
|
int Time3 = (int) (Now.get(Calendar.SECOND) * 6 + Now.get(Calendar.MILLISECOND) * 0.006);
|
68
|
+
|
69
|
+
grf.setColor(Color.black);
|
70
|
+
for(int i=0;i<360;i+=6){
|
71
|
+
x = (int) Math.round( ( r * Math.sin( i * 2.0 * Math.PI / 360.0 ) ) );
|
72
|
+
y = (int) Math.round( ( r * Math.cos( (360.0 - i) * 2.0 * Math.PI / 360.0 ) ) );
|
73
|
+
grf.drawLine( x + r + yohaku, y * (-1) + r + yohaku, x + r + yohaku, y * (-1) + r + yohaku );
|
74
|
+
}
|
75
|
+
|
76
|
+
g.drawImage(offs,0,0,this);
|
77
|
+
}
|
78
|
+
|
79
|
+
public void start() {
|
80
|
+
if(kicker == null) {
|
81
|
+
kicker = new Thread(this);
|
82
|
+
kicker.start();
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
public void stop() {
|
87
|
+
if(kicker != null) {
|
88
|
+
// kicker.stop();
|
89
|
+
kicker = null;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
33
93
|
```
|