-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBanner.java
More file actions
40 lines (34 loc) · 1.1 KB
/
Copy pathBanner.java
File metadata and controls
40 lines (34 loc) · 1.1 KB
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
/* Java Program to Create a Banner using Applet */
import java.applet.*;
import java.awt.*;
public class Banner extends Applet implements Runnable {
String text = "Sample Banner";
Thread t;
// Initialize the applet
public void init() {
setBackground(Color.white);
}
// Function to start the thread
public void start() {
t = new Thread(this);
t.start();
}
// Function to execute the thread
public void run() {
while (true) {
try {
repaint(); // Repaint the applet
Thread.sleep(1000); // Delay each thread by 1000ms or 1 second
// Shift the first character of the banner text to the last position
text = text.substring(1) + text.charAt(0);
} catch (Exception e) {
}
}
}
// Function to draw text
public void paint(Graphics g) {
g.setFont(new Font("TimesRoman", Font.BOLD, 15));
g.drawString(text, 200, 200);
}
}
/* <applet code=Banner.class width=500 height=500> </applet> */