-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.java
More file actions
30 lines (24 loc) · 725 Bytes
/
Cell.java
File metadata and controls
30 lines (24 loc) · 725 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
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JButton;
public class Cell extends JButton {
ColorPalette colorPalette = new ColorPalette();
public Cell(int size) {
setBackground(new Color(255, 255, 255));
setPreferredSize(new Dimension(500 / size, 500 / size));
setFont(new Font("Geneva", Font.BOLD, 30 - size * 2));
setFocusable(false);
}
public void update(int val) {
update(String.valueOf(val));
}
public void update(String val) {
setText(val);
setBackground(colorPalette.getColor(val));
}
public void gameover() {
setBackground(colorPalette.getColor("gameover"));
setEnabled(false);
}
}