Biblioteca Java - Blame information for rev 24
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
24 | mihai | 1 | package rectangles.move; |
2 | |||
3 | import java.util.Observable; | ||
4 | import java.util.Random; | ||
5 | |||
6 | public class Rectangle extends Thread { | ||
7 | int x; | ||
8 | int y; | ||
9 | int prevX; | ||
10 | int speed; | ||
11 | Window w; | ||
12 | |||
13 | public Rectangle(Window w, int x, int y, int speed) { | ||
14 | super(); | ||
15 | this.x = x; | ||
16 | this.y = y; | ||
17 | this.speed = speed; | ||
18 | this.w = w; | ||
19 | } | ||
20 | |||
21 | public void run(){ | ||
22 | while(x<200){ | ||
23 | prevX = x; | ||
24 | x+=speed; | ||
25 | w.repaint(); | ||
26 | try { | ||
27 | Thread.sleep(100); | ||
28 | } catch (InterruptedException e) { | ||
29 | // TODO Auto-generated catch block | ||
30 | e.printStackTrace(); | ||
31 | } | ||
32 | } | ||
33 | } | ||
34 | |||
35 | |||
36 | } |