blob: 2790de8b92715f9c0ef31de50226e428e1f4a5dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/* Listing3406.java */
import java.awt.*;
import java.awt.event.*;
public class Listing3406
extends Frame
{
int cnt = 0;
public static void main(String[] args)
{
Listing3406 wnd = new Listing3406();
wnd.setSize(250,150);
wnd.setVisible(true);
wnd.startAnimation();
}
public Listing3406()
{
super("Animierter Z�hler");
setBackground(Color.lightGray);
addWindowListener(new WindowClosingAdapter(true));
}
public void startAnimation()
{
while (true) {
repaint();
}
}
public void paint(Graphics g)
{
++cnt;
g.drawString("Counter = "+cnt,10,50);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
|