JAVA fall:
import java.awt.*;
import java.applet.*;
/*
<applet code="JavaFall"
width=300 height=50>
</applet>
*/
public class JavaFall extends Applet
implements Runnable {
Thread t = null;
String msg1, msg2, msg3, msg4;
char ch;
int UserX = 100, UserY = 250;
int i = 0, j = 0, k = 0, k1 = 0, k2 = 0, k3 = 0, k4 = 0, count = 0;
boolean stopFlag;
// Set colors and initialize thread.
public void init() {
msg1 = "J";
msg2 = "A";
msg3 = "V";
msg4 = "A";
setBackground(Color.gray);
setForeground(Color.red);
setFont(new Font("serif", Font.BOLD, 30));
}
// Start thread
public void start() {
t = new Thread(this, "eyeThread");
stopFlag = false;
t.start();
}
// Entry point for the thread that runs
the banner.
public void run() {
/* for( ; ; )
{ */
try {
for (i = 0; i < 4; i++) {
j += 50;
for (; k < 100; k += 10) {
Thread.sleep(2000);
repaint();
count++;
if (stopFlag) {
break;
}
if (count == 1) {
k1 = 100;
}
if (count == 2) {
k2 = 100;
}
if (count == 3) {
k3 = 100;
}
if (count == 4) {
k4 = 100;
}
/* repaint();
Thread.sleep(200);
k1=0;k2=0;k3=0;k4=0;
*/
}
}
} catch (InterruptedException e) {
}
/* }*/
}
// Pause the banner.
public void stop() {
stopFlag = true;
t = null;
}
// Display the banner.
public void paint(Graphics g) {
g.drawString(msg1, k1 + (-60), 50);
g.drawString(msg2, k2 + (-60), 100);
g.drawString(msg3, k3 + (-60), 150);
g.drawString(msg4, k4 + (-60), 200);
int xpoints1[] = {1, UserX - 1, UserX - 1, 1};
int ypoints1[] = {1, 1, UserY - 1, UserY - 1};
int num1 = 4;
g.drawPolygon(xpoints1, ypoints1, num1);
int xpoints2[] = {2, UserX - 2, UserX - 2, 2};
int ypoints2[] = {2, 2, UserY - 2, UserY - 2};
int num2 = 4;
g.drawPolygon(xpoints2, ypoints2, num2);
}
}
No comments:
Post a Comment