this program is supposted to write an String in the Applet than String is supposted to go up in the applet untill it reaches top of it. Im getting error at
try {
Thread.currentThread().sleep(20);
}
The static method Sleep void schould be run as acessed the static way.
Any ideas?
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Zad2b extends Applet implements Runnable {
napis n;
Thread t;
public void init() {
Dimension d = getSize();
Color c = new Color((float) Math.random(), (float) Math.random(),
(float) Math.random());
n = new napis(getParameter("napis"), (d.getWidth() / 2) - 30,
d.getHeight(), c);
t = new Thread(this);
t.start();
n.start();
}
public void paint(Graphics g) {
n.rysuj(g);
}
public void run() {
while (true) {
repaint();
try {
Thread.currentThread().sleep(20);
} catch (InterruptedException e) {
}
}
}
class napis extends Thread {
double x, y;
String s;
Color c;
public napis(String s, double x, double y, Color c) {
this.x = x;
this.y = y;
this.s = s;
this.c = c;
}
public void rysuj(Graphics g) {
g.setColor(c);
g.drawString(s, (int) x, (int) y);
}
public void run() {
while (y > 0) {
y -= 1.0;
try {
Thread.currentThread().sleep(5);
} catch (InterruptedException e) {
}
}
}
}
}