-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathActionButton.java
More file actions
108 lines (95 loc) · 2.13 KB
/
ActionButton.java
File metadata and controls
108 lines (95 loc) · 2.13 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
public class ActionButton {
public int x;
public int y;
public int xW;
public int yW;
public boolean hasOption=true;
public boolean hasOtherOption=true;
public boolean hasNum=true;
String label="";
Color color=Color.WHITE;
Color stringColor=Color.BLACK;
Graphics page;
boolean toggled=false;
boolean selected=false;
public ActionButton(Graphics p, int a, int b, int c,int d, String s) {
page=p;
x=a;
y=b;
xW=c;
yW=d;
label=s;
}
public void printButton()
{
page.setColor(Color.BLACK);
page.fillRect(x,y,xW,yW);
toggleSelect();
page.setColor(color);
page.fillRect(x+1,y+1,xW-2,yW-2);
page.setColor(stringColor);
page.drawString(label,x+2,y+yW/2);
}
public void printButtonTrans()
{
page.setColor(Color.BLACK);
page.drawRect(x,y,xW-1,yW-1);
toggleSelect();
page.setColor(color);
if(!color.equals(Color.WHITE))
page.fillRect(x+1,y+1,xW-2,yW-2);
page.setColor(stringColor);
page.drawString(label,x+2,y+yW/2);
}
public void toggle()
{
toggled=!toggled;
if(toggled)
color=Color.GREEN;
else
color=Color.WHITE;
}
public boolean pointIsWithin(int a,int b)
{
if(a>=x&&a<=x+xW&&b>=y&&b<=y+yW)
return true;
return false;
}
public void setColor(Color a)
{
color=a;
}
public void toggleSelect()
{
if(toggled&&selected)
{
color=Color.BLUE;
}
else if(toggled&&!selected)
color=Color.GREEN;
else if(!toggled&&!selected)
color=new Color(0,255/3,255);
else
color=Color.RED;
}
public void selected(boolean a)
{
selected=a;
}
public void setLabel(String s)
{
label=s;
}
public void setOption(boolean a)
{
hasOption=a;
}
}