Biblioteca Java - Blame information for rev 24
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
24 | mihai | 1 | package rectangles.move; |
2 | |||
3 | import java.awt.Color; | ||
4 | import java.awt.Graphics; | ||
5 | import java.util.ArrayList; | ||
6 | |||
7 | import javax.swing.JFrame; | ||
8 | import javax.swing.JProgressBar; | ||
9 | |||
10 | public class Window extends JFrame { | ||
11 | ArrayList<Rectangle> list = new ArrayList<Rectangle>(); | ||
12 | |||
13 | public Window() { | ||
14 | setLayout(null); | ||
15 | setSize(450, 400); | ||
16 | setDefaultCloseOperation(EXIT_ON_CLOSE); | ||
17 | this.setVisible(true); | ||
18 | } | ||
19 | |||
20 | void addRectangle(Rectangle r){ | ||
21 | list.add(r); | ||
22 | } | ||
23 | |||
24 | public void paint(Graphics g){ | ||
25 | if(list!=null) | ||
26 | for(Rectangle r: list ){ | ||
27 | g.setColor(Color.white); | ||
28 | g.fillRect(r.prevX, r.y, 30, 30); | ||
29 | g.setColor(Color.black); | ||
30 | g.fillRect(r.x, r.y, 30, 30); | ||
31 | } | ||
32 | } | ||
33 | } |