Biblioteca Java - Rev 24
Subversion Repositories:
package rectangles.move;
import java.util.Observable;
import java.util.Random;
public class Rectangle extends Thread {
int x;
int y;
int prevX;
int speed;
Window w;
public Rectangle(Window w, int x, int y, int speed) {
super();
this.x = x;
this.y = y;
this.speed = speed;
this.w = w;
}
public void run(){
while(x<200){
prevX = x;
x+=speed;
w.repaint();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
import java.util.Observable;
import java.util.Random;
public class Rectangle extends Thread {
int x;
int y;
int prevX;
int speed;
Window w;
public Rectangle(Window w, int x, int y, int speed) {
super();
this.x = x;
this.y = y;
this.speed = speed;
this.w = w;
}
public void run(){
while(x<200){
prevX = x;
x+=speed;
w.repaint();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}