-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaskableBox.java
45 lines (38 loc) · 1.19 KB
/
MaskableBox.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
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;
public class MaskableBox extends ClickableBox {
private boolean mask;
private Color maskColor;
Container parent;
public MaskableBox(int x, int y, int width, int height, Color borderColor, Color backColor, boolean drawBorder,
Container parent) {
super(x, y, width, height, borderColor, backColor, drawBorder, parent);
this.parent = parent;
}
public void draw(Graphics g) {
super.draw(g);
if(mask) {
setOldColor(g.getColor());
g.setColor(maskColor);
g.fillRect(getX(), getY(), getWidth(), getHeight());
if(isDrawBorder()) {
g.setColor(getBorderColor());
g.drawRect(getX(), getY(), getWidth(), getHeight());
}
g.setColor(getOldColor());
}
}
public boolean isMask() {
return mask;
}
public void setMask(boolean mask) {
this.mask = mask;
}
public Color getMaskColor() {
return maskColor;
}
public void setMaskColor(Color maskColor) {
this.maskColor = maskColor;
}
}