-
Notifications
You must be signed in to change notification settings - Fork 0
/
KurodokoButton.java
46 lines (38 loc) · 1 KB
/
KurodokoButton.java
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
40
41
42
43
44
45
46
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class KurodokoButton extends JButton implements ActionListener, PuzzleButton {
private Kurodoko k;
private int row;
private int col;
private Color color;
public KurodokoButton(Kurodoko k, int row, int col) {
this.row = row;
this.col = col;
this.k = k;
this.addActionListener(this);
}
@Override
public void setCorrect () {
this.setBackground((Color.lightGray));
this.setOpaque(true);
repaint();
}
@Override
public void setEmpty() {
this.setBackground(Color.WHITE);
this.setOpaque(true);
repaint();
}
@Override
public void actionPerformed(ActionEvent e) {
k.setSpot(row, col);
if(k.getSpot(row, col) == 1) {
this.setBackground(Color.lightGray);
}
else {
this.setBackground(Color.WHITE);
}
}
}