-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBlock.java
More file actions
39 lines (30 loc) · 737 Bytes
/
Block.java
File metadata and controls
39 lines (30 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package tetris;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;
/**
* One block, the atomic unit.
* @author dev
*
*/
@SuppressWarnings("serial")
public class Block extends JPanel {
Rectangle r;
public Block() {
super();
this.setBackground(Color.BLACK);
this.setVisible(true);
this.setSize(Board.BLOCKSIZE, Board.BLOCKSIZE);
this.setBorder(new BevelBorder(BevelBorder.RAISED));
}
public void setColor(Color color) {
this.setBackground(color);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(getBackground());
g.fillRect(getX(), getY(), Board.BLOCKSIZE, Board.BLOCKSIZE);
}
}