-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathFieldFrame.java
501 lines (444 loc) · 14.2 KB
/
FieldFrame.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
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
import javax.swing.*;
import java.awt.*;
import java.util.HashMap;
/**
* Created by Jeka on 15.10.2014.
*/
public class FieldFrame extends JFrame{
protected static final int SIZE_OF_BUTTONS_AND_LABELS=25;
protected transient JButton a1;
protected transient JButton a2;
protected transient JButton a3;
protected transient JButton a4;
protected transient JButton a5;
protected transient JButton a6;
protected transient JButton a7;
protected transient JButton a8;
protected transient JButton a9;
protected transient JButton a10;
protected transient JButton b1;
protected transient JButton b2;
protected transient JButton b3;
protected transient JButton b4;
protected transient JButton b5;
protected transient JButton b6;
protected transient JButton b7;
protected transient JButton b8;
protected transient JButton b9;
protected transient JButton b10;
protected transient JButton c1;
protected transient JButton c2;
protected transient JButton c3;
protected transient JButton c4;
protected transient JButton c5;
protected transient JButton c6;
protected transient JButton c7;
protected transient JButton c8;
protected transient JButton c9;
protected transient JButton c10;
protected transient JButton d1;
protected transient JButton d2;
protected transient JButton d3;
protected transient JButton d4;
protected transient JButton d5;
protected transient JButton d6;
protected transient JButton d7;
protected transient JButton d8;
protected transient JButton d9;
protected transient JButton d10;
protected transient JButton e1;
protected transient JButton e2;
protected transient JButton e3;
protected transient JButton e4;
protected transient JButton e5;
protected transient JButton e6;
protected transient JButton e7;
protected transient JButton e8;
protected transient JButton e9;
protected transient JButton e10;
protected transient JButton f1;
protected transient JButton f2;
protected transient JButton f3;
protected transient JButton f4;
protected transient JButton f5;
protected transient JButton f6;
protected transient JButton f7;
protected transient JButton f8;
protected transient JButton f9;
protected transient JButton f10;
protected transient JButton g1;
protected transient JButton g2;
protected transient JButton g3;
protected transient JButton g4;
protected transient JButton g5;
protected transient JButton g6;
protected transient JButton g7;
protected transient JButton g8;
protected transient JButton g9;
protected transient JButton g10;
protected transient JButton h1;
protected transient JButton h2;
protected transient JButton h3;
protected transient JButton h4;
protected transient JButton h5;
protected transient JButton h6;
protected transient JButton h7;
protected transient JButton h8;
protected transient JButton h9;
protected transient JButton h10;
protected transient JButton i1;
protected transient JButton i2;
protected transient JButton i3;
protected transient JButton i4;
protected transient JButton i5;
protected transient JButton i6;
protected transient JButton i7;
protected transient JButton i8;
protected transient JButton i9;
protected transient JButton i10;
protected transient JButton j1;
protected transient JButton j2;
protected transient JButton j3;
protected transient JButton j4;
protected transient JButton j5;
protected transient JButton j6;
protected transient JButton j7;
protected transient JButton j8;
protected transient JButton j9;
protected transient JButton j10;
protected HashMap<Integer,JButton> buttons;
//protected List<JButton> buttons;
public FieldFrame(){
Dimension dimension=new Dimension(SIZE_OF_BUTTONS_AND_LABELS,SIZE_OF_BUTTONS_AND_LABELS);
//Buttons
//buttons=new ArrayList<JButton>();
buttons=new HashMap<Integer, JButton>();
a1=new JButton();
a2=new JButton();
a3=new JButton();
a4=new JButton();
a5=new JButton();
a6=new JButton();
a7=new JButton();
a8=new JButton();
a9=new JButton();
a10=new JButton();
b1=new JButton();
b2=new JButton();
b3=new JButton();
b4=new JButton();
b5=new JButton();
b6=new JButton();
b7=new JButton();
b8=new JButton();
b9=new JButton();
b10=new JButton();
c1=new JButton();
c2=new JButton();
c3=new JButton();
c4=new JButton();
c5=new JButton();
c6=new JButton();
c7=new JButton();
c8=new JButton();
c9=new JButton();
c10=new JButton();
d1=new JButton();
d2=new JButton();
d3=new JButton();
d4=new JButton();
d5=new JButton();
d6=new JButton();
d7=new JButton();
d8=new JButton();
d9=new JButton();
d10=new JButton();
e1=new JButton();
e2=new JButton();
e3=new JButton();
e4=new JButton();
e5=new JButton();
e6=new JButton();
e7=new JButton();
e8=new JButton();
e9=new JButton();
e10=new JButton();
f1=new JButton();
f2=new JButton();
f3=new JButton();
f4=new JButton();
f5=new JButton();
f6=new JButton();
f7=new JButton();
f8=new JButton();
f9=new JButton();
f10=new JButton();
g1=new JButton();
g2=new JButton();
g3=new JButton();
g4=new JButton();
g5=new JButton();
g6=new JButton();
g7=new JButton();
g8=new JButton();
g9=new JButton();
g10=new JButton();
h1=new JButton();
h2=new JButton();
h3=new JButton();
h4=new JButton();
h5=new JButton();
h6=new JButton();
h7=new JButton();
h8=new JButton();
h9=new JButton();
h10=new JButton();
i1=new JButton();
i2=new JButton();
i3=new JButton();
i4=new JButton();
i5=new JButton();
i6=new JButton();
i7=new JButton();
i8=new JButton();
i9=new JButton();
i10=new JButton();
j1=new JButton();
j2=new JButton();
j3=new JButton();
j4=new JButton();
j5=new JButton();
j6=new JButton();
j7=new JButton();
j8=new JButton();
j9=new JButton();
j10=new JButton();
//Add buttons in array list
//buttons.add(0,a1);
buttons.put(0,a1);
buttons.put(1,a2);
buttons.put(2,a3);
buttons.put(3,a4);
buttons.put(4,a5);
buttons.put(5,a6);
buttons.put(6,a7);
buttons.put(7,a8);
buttons.put(8,a9);
buttons.put(9,a10);
buttons.put(10,b1);
buttons.put(11,b2);
buttons.put(12,b3);
buttons.put(13,b4);
buttons.put(14,b5);
buttons.put(15,b6);
buttons.put(16,b7);
buttons.put(17,b8);
buttons.put(18,b9);
buttons.put(19,b10);
buttons.put(20,c1);
buttons.put(21,c2);
buttons.put(22,c3);
buttons.put(23,c4);
buttons.put(24,c5);
buttons.put(25,c6);
buttons.put(26,c7);
buttons.put(27,c8);
buttons.put(28,c9);
buttons.put(29,c10);
buttons.put(30,d1);
buttons.put(31,d2);
buttons.put(32,d3);
buttons.put(33,d4);
buttons.put(34,d5);
buttons.put(35,d6);
buttons.put(36,d7);
buttons.put(37,d8);
buttons.put(38,d9);
buttons.put(39,d10);
buttons.put(40,e1);
buttons.put(41,e2);
buttons.put(42,e3);
buttons.put(43,e4);
buttons.put(44,e5);
buttons.put(45,e6);
buttons.put(46,e7);
buttons.put(47,e8);
buttons.put(48,e9);
buttons.put(49,e10);
buttons.put(50,f1);
buttons.put(51,f2);
buttons.put(52,f3);
buttons.put(53,f4);
buttons.put(54,f5);
buttons.put(55,f6);
buttons.put(56,f7);
buttons.put(57,f8);
buttons.put(58,f9);
buttons.put(59,f10);
buttons.put(60,g1);
buttons.put(61,g2);
buttons.put(62,g3);
buttons.put(63,g4);
buttons.put(64,g5);
buttons.put(65,g6);
buttons.put(66,g7);
buttons.put(67,g8);
buttons.put(68,g9);
buttons.put(69,g10);
buttons.put(70,h1);
buttons.put(71,h2);
buttons.put(72,h3);
buttons.put(73,h4);
buttons.put(74,h5);
buttons.put(75,h6);
buttons.put(76,h7);
buttons.put(77,h8);
buttons.put(78,h9);
buttons.put(79,h10);
buttons.put(80,i1);
buttons.put(81,i2);
buttons.put(82,i3);
buttons.put(83,i4);
buttons.put(84,i5);
buttons.put(85,i6);
buttons.put(86,i7);
buttons.put(87,i8);
buttons.put(88,i9);
buttons.put(89,i10);
buttons.put(90,j1);
buttons.put(91,j2);
buttons.put(92,j3);
buttons.put(93,j4);
buttons.put(94,j5);
buttons.put(95,j6);
buttons.put(96,j7);
buttons.put(97,j8);
buttons.put(98,j9);
buttons.put(99,j10);
for (int i=0; i<buttons.size(); i++){
buttons.get(i).setPreferredSize(dimension);
}
//Labels
JLabel aLabel=new JLabel("a",SwingConstants.CENTER);
JLabel bLabel=new JLabel("b",SwingConstants.CENTER);
JLabel cLabel=new JLabel("c",SwingConstants.CENTER);
JLabel dLabel=new JLabel("d",SwingConstants.CENTER);
JLabel eLabel=new JLabel("e",SwingConstants.CENTER);
JLabel fLabel=new JLabel("f",SwingConstants.CENTER);
JLabel gLabel=new JLabel("g",SwingConstants.CENTER);
JLabel hLabel=new JLabel("h",SwingConstants.CENTER);
JLabel iLabel=new JLabel("i",SwingConstants.CENTER);
JLabel jLabel=new JLabel("j",SwingConstants.CENTER);
JLabel emptyLabel=new JLabel();
JLabel oneLabel=new JLabel("1",SwingConstants.CENTER);
JLabel twoLabel=new JLabel("2",SwingConstants.CENTER);
JLabel threeLabel=new JLabel("3",SwingConstants.CENTER);
JLabel fourLabel=new JLabel("4",SwingConstants.CENTER);
JLabel fiveLabel=new JLabel("5",SwingConstants.CENTER);
JLabel sixLabel=new JLabel("6",SwingConstants.CENTER);
JLabel sevenLabel=new JLabel("7",SwingConstants.CENTER);
JLabel eightLabel=new JLabel("8",SwingConstants.CENTER);
JLabel nineLabel=new JLabel("9",SwingConstants.CENTER);
JLabel tenLabel=new JLabel("10",SwingConstants.CENTER);
emptyLabel.setPreferredSize(dimension);
aLabel.setPreferredSize(dimension);
bLabel.setPreferredSize(dimension);
cLabel.setPreferredSize(dimension);
dLabel.setPreferredSize(dimension);
eLabel.setPreferredSize(dimension);
fLabel.setPreferredSize(dimension);
gLabel.setPreferredSize(dimension);
hLabel.setPreferredSize(dimension);
iLabel.setPreferredSize(dimension);
jLabel.setPreferredSize(dimension);
oneLabel.setPreferredSize(dimension);
twoLabel.setPreferredSize(dimension);
threeLabel.setPreferredSize(dimension);
fourLabel.setPreferredSize(dimension);
fiveLabel.setPreferredSize(dimension);
sixLabel.setPreferredSize(dimension);
sevenLabel.setPreferredSize(dimension);
eightLabel.setPreferredSize(dimension);
nineLabel.setPreferredSize(dimension);
tenLabel.setPreferredSize(dimension);
//Panels
JPanel leftPanel=new JPanel();
leftPanel.setPreferredSize(new Dimension(275,275));
leftPanel.setLayout(new GridLayout(11,11));
//Add all buttons and labels at the panels
//Left panel
//1th row
leftPanel.add(emptyLabel);//1
leftPanel.add(oneLabel);//2
leftPanel.add(twoLabel);//3
leftPanel.add(threeLabel);//4
leftPanel.add(fourLabel);//5
leftPanel.add(fiveLabel);//6
leftPanel.add(sixLabel);//7
leftPanel.add(sevenLabel);//8
leftPanel.add(eightLabel);//9
leftPanel.add(nineLabel);//10
leftPanel.add(tenLabel);//11
//2th row
leftPanel.add(aLabel);
for (int i=0; i<10; i++) {
leftPanel.add(buttons.get(i));
}
//3th row
leftPanel.add(bLabel);
for (int i=10; i<20; i++) {
leftPanel.add(buttons.get(i));
}
//4th row
leftPanel.add(cLabel);
for (int i=20; i<30; i++) {
leftPanel.add(buttons.get(i));
}
//5th row
leftPanel.add(dLabel);
for (int i=30; i<40; i++) {
leftPanel.add(buttons.get(i));
}
//6th row
leftPanel.add(eLabel);
for (int i=40; i<50; i++) {
leftPanel.add(buttons.get(i));
}
//7th row
leftPanel.add(fLabel);
for (int i=50; i<60; i++) {
leftPanel.add(buttons.get(i));
}
//8th row
leftPanel.add(gLabel);
for (int i=60; i<70; i++) {
leftPanel.add(buttons.get(i));
}
//9th row
leftPanel.add(hLabel);
for (int i=70; i<80; i++) {
leftPanel.add(buttons.get(i));
}
//10th row
leftPanel.add(iLabel);
for (int i=80; i<90; i++) {
leftPanel.add(buttons.get(i));
}
//11th row
leftPanel.add(jLabel);
for (int i=90; i<100; i++) {
leftPanel.add(buttons.get(i));
}
this.setLayout(new FlowLayout(FlowLayout.LEFT));
this.getContentPane().add(leftPanel);
this.setSize(275,275);
this.setResizable(false);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
pack();
}
public void setEnabledAllButtons(boolean condition){
}
public HashMap<Integer, JButton> getButtons() {
return buttons;
}
}