-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandsPanel.java
More file actions
264 lines (228 loc) · 7.4 KB
/
CommandsPanel.java
File metadata and controls
264 lines (228 loc) · 7.4 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
// CommandsPanel.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class CommandsPanel extends JPanel
{
JButton pickUpButton;
public CommandsPanel()
{
Dimension size = getPreferredSize();
size.width = 1000;
//size.height = 1000;
setPreferredSize(size);
setLayout(new GridBagLayout());
GridBagConstraints gc = new GridBagConstraints();
setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.WHITE, 1),
"List of Commands",
TitledBorder.CENTER,
TitledBorder.TOP,
new Font("Sans Serif", Font.BOLD, 12),
Color.WHITE));
JButton letterButton = new JButton("LETTER");
initializeButton(letterButton, "Click to create a new letter.");
letterButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
LetterWindow lw = new LetterWindow(CommandsPanel.this);
lw.getContentPane().setBackground(Color.DARK_GRAY.brighter());
lw.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
lw.setSize(380, 300);
lw.setLocation(10, 650);
lw.setTitle("Create LETTER command");
lw.setVisible(true);
}
});
JButton packageButton = new JButton("PACKAGE");
initializeButton(packageButton, "Click to create a new package.");
packageButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
PackageWindow pw = new PackageWindow(CommandsPanel.this);
pw.getContentPane().setBackground(Color.DARK_GRAY.brighter());
pw.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
pw.setSize(380, 350);
pw.setLocation(10, 650);
pw.setTitle("Create PACKAGE command");
pw.setVisible(true);
}
});
pickUpButton = new JButton("PICKUP");
initializeButton(pickUpButton, "Click to create a pickup attempt.");
pickUpButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
PickUpWindow pw = new PickUpWindow(CommandsPanel.this);
pw.getContentPane().setBackground(Color.DARK_GRAY.brighter());
pw.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
pw.setSize(380, 200);
pw.setLocation(10, 650);
pw.setTitle("Create PICKUP command");
pw.setVisible(true);
}
});
JButton sneakButton = new JButton("SNEAK");
initializeButton(sneakButton, "Click to sneak the next item to the post office successfully.");
sneakButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
fireDetailEvent(new DetailEvent(this, "SNEAK"));
}
});
JButton nsaDelayButton = new JButton("NSADELAY");
initializeButton(nsaDelayButton, "Click to delay someone's mail.");
nsaDelayButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
DelayWindow dw = new DelayWindow(CommandsPanel.this);
dw.getContentPane().setBackground(Color.DARK_GRAY.brighter());
dw.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
dw.setSize(380, 200);
dw.setLocation(10, 650);
dw.setTitle("Create NSADELAY command");
dw.setVisible(true);
}
});
JButton scienceButton = new JButton("SCIENCE");
initializeButton(scienceButton, "Click to create a time travel event.");
scienceButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
ScienceWindow sw = new ScienceWindow(CommandsPanel.this);
sw.getContentPane().setBackground(Color.DARK_GRAY.brighter());
sw.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
sw.setSize(380, 200);
sw.setLocation(10, 650);
sw.setTitle("Create SCIENCE command");
sw.setVisible(true);
}
});
JButton inflationButton = new JButton("INFLATION");
initializeButton(inflationButton, "Click to inflate the costs in all post offices.");
inflationButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
fireDetailEvent(new DetailEvent(this, "INFLATION"));
}
});
JButton deflationButton = new JButton("DEFLATION");
initializeButton(deflationButton, "Click to deflate the costs in all post offices.");
deflationButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
fireDetailEvent(new DetailEvent(this, "DEFLATION"));
}
});
JButton buildButton = new JButton("BUILD");
initializeButton(buildButton, "Click to create a new post office.");
buildButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
BuildWindow bw = new BuildWindow(CommandsPanel.this);
bw.getContentPane().setBackground(Color.DARK_GRAY.brighter());
bw.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
bw.setSize(380, 375);
bw.setLocation(10, 650);
bw.setTitle("Create BUILD command");
bw.setVisible(true);
}
});
JButton goodButton = new JButton("GOOD");
initializeButton(goodButton, "Click to attempt skipping to the end of the day.");
goodButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
fireDetailEvent(new DetailEvent(this, "GOOD"));
}
});
JButton dayButton = new JButton("DAY");
initializeButton(dayButton, "Click to signify the end of day.");
dayButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
fireDetailEvent(new DetailEvent(this, "DAY"));
}
});
gc.weightx = 0.5;
gc.weighty = 0.5;
gc.ipadx = 100;
gc.ipady = 50;
gc.insets = new Insets(5, 5, 5, 5); // top, left, bottom, right
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 0;
gc.gridy = 0;
add(letterButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 1;
gc.gridy = 0;
add(packageButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 0;
gc.gridy = 1;
add(pickUpButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 1;
gc.gridy = 1;
add(sneakButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 0;
gc.gridy = 2;
add(nsaDelayButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 1;
gc.gridy = 2;
add(scienceButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 0;
gc.gridy = 3;
add(inflationButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 1;
gc.gridy = 3;
add(deflationButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 0;
gc.gridy = 4;
add(buildButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 1;
gc.gridy = 4;
add(goodButton, gc);
gc.fill = GridBagConstraints.BOTH;
gc.gridx = 1;
gc.gridy = 5;
add(dayButton, gc);
}
void initializeButton(JButton button, String text)
{
button.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));
button.setBackground(new Color(255, 255, 17));
button.setForeground(Color.BLACK);
button.setFont(new Font("Sans Serif", Font.BOLD, 16));
button.setToolTipText(text);
}
public void fireDetailEvent(DetailEvent event)
{
Object[] listeners = listenerList.getListenerList();
for(int i = 0; i < listeners.length; i += 2)
{
if(listeners[i] == DetailListener.class)
{
((DetailListener) listeners[i+1]).detailEventOccurred(event);
}
}
}
public void addDetailListener(DetailListener listener)
{
listenerList.add(DetailListener.class, listener);
}
public void removeDetailListener(DetailListener listener)
{
listenerList.remove(DetailListener.class, listener);
}
public void returnText(String text)
{
fireDetailEvent(new DetailEvent(this, text));
}
}