-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.java
More file actions
47 lines (42 loc) · 861 Bytes
/
Button.java
File metadata and controls
47 lines (42 loc) · 861 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
40
41
42
43
44
45
46
47
import java.awt.Color;
import javax.swing.JButton;
public class Button extends JButton {
public static final int NONE = 0;
public static final int COMPARE = 1;
public static final int SWAP = 2;
public static final int SECURED = 3;
private int state;
public Button() {
super();
setState(0);
}
public void setState(int state) {
if(this.state == SECURED) {
return;
}
this.state = state;
switch (state) {
case NONE:
setBackground(Color.WHITE);
break;
case COMPARE:
setBackground(Color.YELLOW);
break;
case SWAP:
setBackground(Color.RED);
break;
case SECURED:
setBackground(Color.GREEN);
break;
default:
break;
}
}
public int getState() {
return state;
}
public void reset(){
state = NONE;
setState(state);
}
}