import
java.applet.*;
import
java.awt.*;
import
java.util.*;
public
class
saat
extends
Applet
implements
Runnable {
Thread Clock_animation;
private
Image Buffer;
private
Graphics gBuffer;
int
oldSec,sec,min,hour,day,date,month,counter;
double
pi =
3.14159
;
double
pi2 =
2
* pi;
String second,minute,hours;
String weekday;String Smonth;
Font a =
new
Font(
"Helvetica"
, Font.ITALIC,
24
);
Font b =
new
Font(
"Helvetica"
, Font.PLAIN,
14
);
Font c =
new
Font(
"Helvetica"
, Font.PLAIN,
18
);
Color c1 =
new
Color(
200
,
200
,
160
);
Color c2 =
new
Color(
0
,
120
,
70
);
public
void
init() {
oldSec=-
1
;
Buffer=createImage(size().width,size().height);
gBuffer=Buffer.getGraphics();
}
public
void
start() {
if
(Clock_animation ==
null
) {
Clock_animation =
new
Thread (
this
);
Clock_animation.start();
}
}
public
void
stop() {
if
(Clock_animation !=
null
) {
Clock_animation.stop();
Clock_animation =
null
;
}
}
public
void
run() {
while
(
true
)
{
try
{Clock_animation.sleep (
50
);}
catch
(Exception e) { }
repaint();
Date d=
new
Date();
sec=d.getSeconds();
if
(sec!=oldSec){
gBuffer.setColor(Color.blue);
gBuffer.setFont(a);
gBuffer.drawString(
":"
,
54
,
83
);
gBuffer.drawString(
":"
,
88
,
83
);
oldSec=sec;
try
{Clock_animation.sleep (
399
);}
catch
(Exception e) { }
repaint();
}
min=d.getMinutes();
hour=d.getHours();
day=d.getDay();
date=d.getDate();
month=d.getMonth();
gBuffer.setColor(c1);
gBuffer.setFont(a);
gBuffer.drawString(
":"
,
54
,
83
);
gBuffer.drawString(
":"
,
88
,
83
);
try
{Clock_animation.sleep (
599
);}
catch
(Exception e) { }
repaint();
gBuffer.setColor(c1);
gBuffer.fill3DRect(
0
,
0
,
150
,
180
,
true
);
gBuffer.fill3DRect(
5
,
5
,
140
,
142
,
true
);
gBuffer.fill3DRect(
5
,
150
,
140
,
25
,
true
);
gBuffer.setColor(Color.yellow);
gBuffer.drawOval(
16
,
16
,
118
,
118
);
gBuffer.setFont(a);
gBuffer.setColor(Color.blue);
if
(hour<
10
)
hours=
"0"
+hour;
else
hours=
""
+hour;
if
(min<
10
)
minute=
"0"
+min;
else
minute=
""
+min;
if
(sec<
10
)
second=
"0"
+sec;
else
second=
""
+sec;
gBuffer.drawString(hours+
" "
+minute+
" "
+second,
28
,
85
);
gBuffer.setColor(Color.green);
gBuffer.drawString(
"Talip"
,
50
,
60
);
gBuffer.drawString(
"Ozturk"
,
40
,
105
);
switch
(day){
case
0
: weekday=
"Pazar"
;
break
;
case
1
: weekday=
"Pazartesi"
;
break
;
case
2
: weekday=
"Sali"
;
break
;
case
3
: weekday=
"Carsamba"
;
break
;
case
4
: weekday=
"Persembe"
;
break
;
case
5
: weekday=
"Cuma"
;
break
;
case
6
: weekday=
"Cumartesi"
;
break
;
}
gBuffer.setColor(Color.red);
gBuffer.setFont(b);
gBuffer.drawString(weekday,
22
,
168
);
gBuffer.setFont(c);
gBuffer.setColor(c2);
if
(date>
9
)
gBuffer.drawString(
""
+date,
64
,
169
);
else
gBuffer.drawString(
"0"
+date,
64
,
169
);
switch
(month){
case
0
: Smonth=
"Ocak"
;
break
;
case
1
: Smonth=
"Subat"
;
break
;
case
2
: Smonth=
"Mart"
;
break
;
case
3
: Smonth=
"Nisan"
;
break
;
case
4
: Smonth=
"Mayis"
;
break
;
case
5
: Smonth=
"Haziran"
;
break
;
case
6
: Smonth=
"Temmuz"
;
break
;
case
7
: Smonth=
"Agustos"
;
break
;
case
8
: Smonth=
"Eylul"
;
break
;
case
9
: Smonth=
"Ekim"
;
break
;
case
10
: Smonth=
"Kasim"
;
break
;
case
11
: Smonth=
"Aralik"
;
break
;
}
gBuffer.setFont(b);
gBuffer.setColor(Color.red);
gBuffer.drawString(Smonth,
105
,
168
);
double
sv = sec * pi2 /
60.0
;
int
sx=(
int
)(
70
+
59
*Math.sin(sv));
int
sy=(
int
)(
70
-
59
*Math.cos(sv));
gBuffer.fillOval (sx,sy,
10
,
10
);
}
}
public
void
update(Graphics g) {
paint(g);
}
public
void
paint(Graphics g) {
g.drawImage (Buffer,
0
,
0
,
this
);
}
}