-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionStatus.java
34 lines (31 loc) · 1.02 KB
/
ActionStatus.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
import javax.swing.*;
import java.awt.*;
/**
* Provides a box which represents whether an action was successful
* or unsuccessful by changing colour to green or red respectively.
*
* @author Jonathan Beaumont
*/
public class ActionStatus extends JPanel {
static final private Color SUCCESS_COLOR = Color.GREEN;
static final private Color FAIL_COLOR = Color.RED;
private static final long serialVersionUID = 2142623422463658797L;
/**
* Constructor. Sets the size of the box.
*
* @param size The size of the box
*/
public ActionStatus(int size) {
this.setPreferredSize(new Dimension(size, size));
this.setMaximumSize(new Dimension(size, size));
this.setMinimumSize(new Dimension(size, size));
this.setBackground(SUCCESS_COLOR);
}
public void actionSuccessful(boolean success) {
if (success) {
this.setBackground(SUCCESS_COLOR);
} else {
this.setBackground(FAIL_COLOR);
}
}
}