-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmBanner.java
More file actions
53 lines (52 loc) · 798 Bytes
/
mBanner.java
File metadata and controls
53 lines (52 loc) · 798 Bytes
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
43
44
45
46
47
48
49
50
51
52
53
import java.awt.*;
import java.applet.*;
/* <Applet code="mBanner" width=500 height=500>
</Applet>
*/
public class mBanner extends Applet implements Runnable
{
String msg;
Thread t;
boolean stopFlag;
public void init()
{
setForeground(Color.black);
setBackground(Color.cyan);
msg = "A simple moving banner ";
}
public void start()
{
t = new Thread(this);
stopFlag = false;
t.start();
}
public void run()
{
char ch;
for(;;)
{
try
{
repaint();
Thread.sleep(250);
ch = msg.charAt(0);
msg = msg.substring(1,msg.length());
msg += ch;
if(stopFlag)
break;
}
catch(InterruptedException e)
{
}
}
}
public void stop()
{
stopFlag = true;
t = null;
}
public void paint(Graphics g)
{
g.drawString(msg,10,30);
}
}