-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTilePanel.java
More file actions
34 lines (28 loc) · 852 Bytes
/
TilePanel.java
File metadata and controls
34 lines (28 loc) · 852 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
// This class keeps track of a set of colored tiles in a panel.
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
public class TilePanel extends JPanel {
private TileList tiles;
private Color color;
public TilePanel(Color color) {
setBackground(Color.WHITE);
tiles = new TileList();
this.color = color;
MouseInputListener listener = new TileListener(tiles, this);
addMouseListener(listener);
addMouseMotionListener(listener);
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (int i = 0; i < tiles.size(); i++) {
tiles.get(i).draw(g);
}
}
}