-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeRaceUi.java
More file actions
718 lines (596 loc) · 29.4 KB
/
Copy pathcodeRaceUi.java
File metadata and controls
718 lines (596 loc) · 29.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
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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
import java.awt.Color;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author SoloCode JSHDVR
*/
public class codeRaceUi extends javax.swing.JFrame {
private static int score;
/**
* Creates new form codeRaceUi
*/
public codeRaceUi() {
initComponents();
this.setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel2 = new javax.swing.JPanel();
loginFormLabel = new javax.swing.JLabel();
exit = new javax.swing.JLabel();
minimize = new javax.swing.JLabel();
backPanel = new javax.swing.JPanel();
gcCCS = new javax.swing.JPanel();
vision = new javax.swing.JButton();
mission = new javax.swing.JButton();
stringCompareButton = new javax.swing.JButton();
goal2 = new javax.swing.JButton();
goal3 = new javax.swing.JButton();
goal4 = new javax.swing.JButton();
ccsVision = new javax.swing.JButton();
ccsMission = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
typeWindow = new javax.swing.JTextArea();
jPanel1 = new javax.swing.JPanel();
s1Result = new javax.swing.JTextField();
s2Result = new javax.swing.JTextField();
totalAverage = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
submitButton = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
submitButton1 = new javax.swing.JButton();
goal1 = new javax.swing.JButton();
accuracyButton = new javax.swing.JButton();
clearButton = new javax.swing.JButton();
errorButton = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
errorAccute = new javax.swing.JLabel();
stringCompare = new javax.swing.JLabel();
jSeparator2 = new javax.swing.JSeparator();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setUndecorated(true);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel2.setBackground(new java.awt.Color(249, 208, 116));
jPanel2.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(java.awt.event.MouseEvent evt) {
jPanel2MouseDragged(evt);
}
});
jPanel2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
jPanel2MousePressed(evt);
}
});
jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
loginFormLabel.setFont(new java.awt.Font("Calisto MT", 1, 24)); // NOI18N
loginFormLabel.setText("CODING OLYMPICS");
jPanel2.add(loginFormLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 10, 270, -1));
exit.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
exit.setForeground(new java.awt.Color(255, 255, 255));
exit.setText("X");
exit.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
exitMouseClicked(evt);
}
});
jPanel2.add(exit, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 10, 20, 20));
minimize.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
minimize.setForeground(new java.awt.Color(255, 255, 255));
minimize.setText("_");
minimize.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
minimizeMouseClicked(evt);
}
});
jPanel2.add(minimize, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 0, 30, 30));
getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 520, 60));
backPanel.setBackground(new java.awt.Color(204, 204, 204));
gcCCS.setBackground(new java.awt.Color(153, 152, 153));
gcCCS.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
vision.setBackground(new java.awt.Color(204, 255, 204));
vision.setFont(new java.awt.Font("Calisto MT", 1, 14)); // NOI18N
vision.setText("GC VISION");
vision.setBorder(null);
vision.setPreferredSize(new java.awt.Dimension(45, 20));
vision.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
visionActionPerformed(evt);
}
});
gcCCS.add(vision, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 190, 30));
mission.setBackground(new java.awt.Color(204, 255, 204));
mission.setFont(new java.awt.Font("Calisto MT", 1, 14)); // NOI18N
mission.setText("GC MISSION");
mission.setBorder(null);
mission.setPreferredSize(new java.awt.Dimension(45, 20));
mission.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
missionActionPerformed(evt);
}
});
gcCCS.add(mission, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 190, 30));
stringCompareButton.setBackground(new java.awt.Color(204, 255, 204));
stringCompareButton.setFont(new java.awt.Font("Calisto MT", 1, 12)); // NOI18N
stringCompareButton.setText("S COMPARE");
stringCompareButton.setBorder(null);
stringCompareButton.setPreferredSize(new java.awt.Dimension(45, 20));
stringCompareButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
stringCompareButtonActionPerformed(evt);
}
});
gcCCS.add(stringCompareButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 330, 100, 30));
goal2.setBackground(new java.awt.Color(204, 255, 204));
goal2.setFont(new java.awt.Font("Calisto MT", 1, 12)); // NOI18N
goal2.setText(" GC GOAL 2");
goal2.setBorder(null);
goal2.setPreferredSize(new java.awt.Dimension(45, 20));
goal2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
goal2ActionPerformed(evt);
}
});
gcCCS.add(goal2, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 70, 100, 30));
goal3.setBackground(new java.awt.Color(204, 255, 204));
goal3.setFont(new java.awt.Font("Calisto MT", 1, 12)); // NOI18N
goal3.setText("GC GOAL 3");
goal3.setBorder(null);
goal3.setPreferredSize(new java.awt.Dimension(45, 20));
goal3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
goal3ActionPerformed(evt);
}
});
gcCCS.add(goal3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, 100, 30));
goal4.setBackground(new java.awt.Color(204, 255, 204));
goal4.setFont(new java.awt.Font("Calisto MT", 1, 12)); // NOI18N
goal4.setText("GC GOAL 4");
goal4.setBorder(null);
goal4.setPreferredSize(new java.awt.Dimension(45, 20));
goal4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
goal4ActionPerformed(evt);
}
});
gcCCS.add(goal4, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 100, 100, 30));
ccsVision.setBackground(new java.awt.Color(249, 208, 116));
ccsVision.setFont(new java.awt.Font("Calisto MT", 1, 14)); // NOI18N
ccsVision.setText("CCS VISION");
ccsVision.setBorder(null);
ccsVision.setPreferredSize(new java.awt.Dimension(45, 20));
ccsVision.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ccsVisionActionPerformed(evt);
}
});
gcCCS.add(ccsVision, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 160, 190, 30));
ccsMission.setBackground(new java.awt.Color(249, 208, 116));
ccsMission.setFont(new java.awt.Font("Calisto MT", 1, 14)); // NOI18N
ccsMission.setText("CCS MISSION");
ccsMission.setBorder(null);
ccsMission.setPreferredSize(new java.awt.Dimension(45, 20));
ccsMission.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ccsMissionActionPerformed(evt);
}
});
gcCCS.add(ccsMission, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 130, 190, 30));
typeWindow.setColumns(20);
typeWindow.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
typeWindow.setLineWrap(true);
typeWindow.setRows(5);
typeWindow.setWrapStyleWord(true);
jScrollPane1.setViewportView(typeWindow);
gcCCS.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 10, 300, 170));
jPanel1.setBackground(new java.awt.Color(170, 170, 170));
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
s1Result.setEditable(false);
s1Result.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
s1Result.setText("0");
s1Result.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
s1ResultActionPerformed(evt);
}
});
jPanel1.add(s1Result, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 0, 70, 30));
s2Result.setEditable(false);
s2Result.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
s2Result.setText("0");
jPanel1.add(s2Result, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 30, 70, 30));
totalAverage.setEditable(false);
totalAverage.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
totalAverage.setText("0");
jPanel1.add(totalAverage, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 60, 70, 30));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setText("A :");
jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(9, 70, 30, -1));
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel2.setText("S2 :");
jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 35, -1, -1));
jSeparator1.setBackground(new java.awt.Color(0, 0, 0));
jPanel1.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 100, 10));
submitButton.setText("\t▶");
submitButton.setToolTipText("TRY AGAIN");
submitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
submitButtonActionPerformed(evt);
}
});
jPanel1.add(submitButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 0, 80, 60));
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel3.setText("S1 :");
jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 8, -1, -1));
submitButton1.setText("SUBMIT");
submitButton1.setToolTipText("");
submitButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
submitButton1ActionPerformed(evt);
}
});
jPanel1.add(submitButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 60, 80, 30));
gcCCS.add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 200, 200, 100));
goal1.setBackground(new java.awt.Color(204, 255, 204));
goal1.setFont(new java.awt.Font("Calisto MT", 1, 12)); // NOI18N
goal1.setText("GC GOAL 1");
goal1.setBorder(null);
goal1.setPreferredSize(new java.awt.Dimension(45, 20));
goal1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
goal1ActionPerformed(evt);
}
});
gcCCS.add(goal1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, 100, 30));
accuracyButton.setBackground(new java.awt.Color(204, 255, 204));
accuracyButton.setFont(new java.awt.Font("Calisto MT", 1, 12)); // NOI18N
accuracyButton.setText("ACCURACY");
accuracyButton.setBorder(null);
accuracyButton.setPreferredSize(new java.awt.Dimension(45, 20));
accuracyButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
accuracyButtonActionPerformed(evt);
}
});
gcCCS.add(accuracyButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 300, 100, 30));
clearButton.setBackground(new java.awt.Color(204, 255, 204));
clearButton.setFont(new java.awt.Font("Calisto MT", 1, 12)); // NOI18N
clearButton.setText("CLEAR");
clearButton.setBorder(null);
clearButton.setPreferredSize(new java.awt.Dimension(45, 20));
clearButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
clearButtonActionPerformed(evt);
}
});
gcCCS.add(clearButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 300, 100, 30));
errorButton.setBackground(new java.awt.Color(204, 255, 204));
errorButton.setFont(new java.awt.Font("Calisto MT", 1, 12)); // NOI18N
errorButton.setText("ERROR");
errorButton.setBorder(null);
errorButton.setPreferredSize(new java.awt.Dimension(45, 20));
errorButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
errorButtonActionPerformed(evt);
}
});
gcCCS.add(errorButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 330, 100, 30));
jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
errorAccute.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
errorAccute.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
errorAccute.setText(" ");
jPanel3.add(errorAccute, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 50, 300, 60));
stringCompare.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
stringCompare.setText(" ");
jPanel3.add(stringCompare, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 290, 160));
gcCCS.add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 200, 290, 160));
jSeparator2.setBackground(new java.awt.Color(0, 0, 0));
gcCCS.add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, 490, 20));
javax.swing.GroupLayout backPanelLayout = new javax.swing.GroupLayout(backPanel);
backPanel.setLayout(backPanelLayout);
backPanelLayout.setHorizontalGroup(
backPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(gcCCS, javax.swing.GroupLayout.DEFAULT_SIZE, 519, Short.MAX_VALUE)
);
backPanelLayout.setVerticalGroup(
backPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(backPanelLayout.createSequentialGroup()
.addComponent(gcCCS, javax.swing.GroupLayout.PREFERRED_SIZE, 391, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
getContentPane().add(backPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 60, -1, 370));
pack();
}// </editor-fold>//GEN-END:initComponents
private void exitMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exitMouseClicked
System.exit(0);
}//GEN-LAST:event_exitMouseClicked
private void minimizeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_minimizeMouseClicked
this.setState(JFrame.ICONIFIED);
}//GEN-LAST:event_minimizeMouseClicked
private void jPanel2MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel2MouseDragged
// TODO add your handling code here:
int positionX =evt.getXOnScreen();
int positionY =evt.getYOnScreen();
this.setLocation(positionX-mousePX,positionY-mousePY);
}//GEN-LAST:event_jPanel2MouseDragged
int mousePX,mousePY;
private void jPanel2MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel2MousePressed
mousePX=evt.getX();
mousePY=evt.getY();
}//GEN-LAST:event_jPanel2MousePressed
private void visionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_visionActionPerformed
}//GEN-LAST:event_visionActionPerformed
private void missionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_missionActionPerformed
}//GEN-LAST:event_missionActionPerformed
private void goal4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goal4ActionPerformed
}//GEN-LAST:event_goal4ActionPerformed
private void stringCompareButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stringCompareButtonActionPerformed
ds.setScore(0);
ds.strCompare();
String x = ds.getCheckedAnswer();
stringCompare.setText(x);
errorAccute.setText("");
}//GEN-LAST:event_stringCompareButtonActionPerformed
private void goal2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goal2ActionPerformed
}//GEN-LAST:event_goal2ActionPerformed
private void goal3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goal3ActionPerformed
}//GEN-LAST:event_goal3ActionPerformed
private void ccsVisionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ccsVisionActionPerformed
// System.out.println(ds.getRandomNum());
}//GEN-LAST:event_ccsVisionActionPerformed
private void ccsMissionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ccsMissionActionPerformed
}//GEN-LAST:event_ccsMissionActionPerformed
private void s1ResultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_s1ResultActionPerformed
// TODO add your handling code here:
score = 0;
}//GEN-LAST:event_s1ResultActionPerformed
static int tryCounter = 0;
private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submitButtonActionPerformed
// TODO add your handling code here:
try{
if ("0".equals(s2Result.getText())) {
int score = 0;
int choiceLen;
char[] tempArrChar,tempArrChar2;
ds.setRandomNum();
ds.setInput(typeWindow.getText());
tempArrChar2 = ds.getInput().toCharArray();
tempArrChar = ds.getArrChoice(ds.getRandomNum()).toCharArray();
System.out.println(ds.getArrChoice(ds.getRandomNum()));
choiceLen = ds.getArrChoice(ds.getRandomNum()).length();
ds.setSize(choiceLen);
tryCounter++;
}
if (!"0".equals(s2Result.getText())) {
int score = 0;
int choiceLen;
char[] tempArrChar,tempArrChar2;
// System.out.println(ds.setRandomNum());
ds.setInput(typeWindow.getText());
tempArrChar2 = ds.getInput().toCharArray();
tempArrChar = ds.getArrChoice(ds.getRandomNum()).toCharArray();
// System.out.println(ds.getArrChoice(ds.getRandomNum()));
choiceLen = ds.getArrChoice(ds.getRandomNum()).length();
ds.setSize(choiceLen);
tryCounter++;
}
}catch (Exception e){
System.out.println(e);
}
// System.out.println(ds.getRandomNum());
switchChoicesColors(ds.getRandomNum());
// typeWindow.setText("");
}//GEN-LAST:event_submitButtonActionPerformed
private void goal1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goal1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_goal1ActionPerformed
private void accuracyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_accuracyButtonActionPerformed
// TODO add your handling code here:
stringCompare.setText("");
ds.setAccuracy();
s1Result.setText(ds.getAccuracy());
// System.out.println(ds.getAccuracy());
errorAccute.setText(s1Result.getText()+"%");
}//GEN-LAST:event_accuracyButtonActionPerformed
private void clearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearButtonActionPerformed
// TODO add your handling code here:
ds.setCheckedAnswer("");
ds.setScore(0);
clearAll();
}//GEN-LAST:event_clearButtonActionPerformed
private void errorButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_errorButtonActionPerformed
// TODO add your handling code here:
stringCompare.setText("");
errorAccute.setText(String.valueOf(ds.getScore())+" / "+String.valueOf(ds.getSize()));
// ds.setAccuracy();
}//GEN-LAST:event_errorButtonActionPerformed
private void submitButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_submitButton1ActionPerformed
// TODO add your handling code here:
ds.setInput(typeWindow.getText());
ds.strCompare();
ds.setAccuracy();
if (tryCounter==1) {
ds.setAccuracy();
s1Result.setText(ds.getAccuracy());
if (Integer.parseInt(ds.getAccuracy())>80) {
totalAverage.setText(ds.getAccuracy());
}
}
if (tryCounter==2) {
ds.setAccuracy();
s2Result.setText(ds.getAccuracy());
double x = Integer.parseInt(ds.getAccuracy());
System.out.println(x);
double y = Double.parseDouble(s1Result.getText());
System.out.println(y);
double result = x+y;
result = result /2;
System.out.println(result);
totalAverage.setText(String.valueOf(result));
}
typeWindow.setText("");
}//GEN-LAST:event_submitButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(codeRaceUi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(codeRaceUi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(codeRaceUi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(codeRaceUi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new codeRaceUi().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton accuracyButton;
private javax.swing.JPanel backPanel;
private javax.swing.JButton ccsMission;
private javax.swing.JButton ccsVision;
private javax.swing.JButton clearButton;
private javax.swing.JLabel errorAccute;
private javax.swing.JButton errorButton;
private javax.swing.JLabel exit;
private javax.swing.JPanel gcCCS;
private javax.swing.JButton goal1;
private javax.swing.JButton goal2;
private javax.swing.JButton goal3;
private javax.swing.JButton goal4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JLabel loginFormLabel;
private javax.swing.JLabel minimize;
private javax.swing.JButton mission;
private javax.swing.JTextField s1Result;
private javax.swing.JTextField s2Result;
private javax.swing.JLabel stringCompare;
private javax.swing.JButton stringCompareButton;
private javax.swing.JButton submitButton;
private javax.swing.JButton submitButton1;
private javax.swing.JTextField totalAverage;
private javax.swing.JTextArea typeWindow;
private javax.swing.JButton vision;
// End of variables declaration//GEN-END:variables
private void clearAll() {
typeWindow.setText("");
stringCompare.setText("");
errorAccute.setText("");
s1Result.setText("");
s2Result.setText("");
totalAverage.setText("");
ds.setInput("");
// vision.setBackground(Color.green);
// mission.setBackground(Color.green);
// goal1.setBackground(Color.green);
// goal2.setBackground(Color.green);
// goal3.setBackground(Color.green);
// goal4.setBackground(Color.green);
// ccsVision.setBackground(Color.orange);
// ccsMission.setBackground(Color.orange);
}
doStuff ds = new doStuff();
//
public void visionChoice() {
//selectedChoice2 = this.vision;
vision.setForeground(Color.white);
vision.setBackground(Color.red);
}
public void missionChoice() {
mission.setForeground(Color.white);
mission.setBackground(Color.red);
}
public void goal1Choice() {
goal1.setForeground(Color.white);
goal1.setBackground(Color.red);
}
public void goal2Choice() {
goal2.setForeground(Color.white);
goal2.setBackground(Color.red);
}
public void goal3Choice() {
goal3.setForeground(Color.white);
goal3.setBackground(Color.red);
}
public void goal4Choice() {
goal4.setForeground(Color.white);
goal4.setBackground(Color.red);
}
public void missionCCSChoice() {
ccsMission.setForeground(Color.white);
ccsMission.setBackground(Color.red);
}
public void vissionCCSChoice() {
ccsVision.setForeground(Color.white);
ccsVision.setBackground(Color.red);
}
public void switchChoicesColors(int x) {
switch (x) {
case 1:
visionChoice();
break;
case 2:
missionChoice();
break;
case 3:
goal1Choice();
break;
case 4:
goal2Choice();
break;
case 5:
goal3Choice();
break;
case 6:
goal4Choice();
break;
case 7:
missionCCSChoice();
break;
case 8:
vissionCCSChoice();
break;
default:
}
}
}