forked from pquiring/javaforce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToggleButton.java
More file actions
44 lines (36 loc) · 781 Bytes
/
Copy pathToggleButton.java
File metadata and controls
44 lines (36 loc) · 781 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
package javaforce.ui;
/** Toggle Button
*
* @author pquiring
*/
import javaforce.*;
public class ToggleButton extends Button {
private boolean selected;
public ToggleButton(String text) {
super(text);
}
public void render(Image image) {
int x = pos.x;
int y = pos.y;
int w = size.width;
int h = size.height;
if (w == 0 || h == 0) return;
if (isSelected()) {
image.setForeColor(getSelectedColor());
} else {
image.setForeColor(getBackColor());
}
image.fill(x, y, w, h);
super.render(image);
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean state) {
selected = state;
}
protected void doAction() {
setSelected(!selected);
super.doAction();
}
}