-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontroller.java
825 lines (731 loc) · 40.7 KB
/
controller.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
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
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
/*
* 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.
*/
import com.sun.corba.se.impl.ior.WireObjectKeyTemplate;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
/**
*
* @author Bhavesh
*/
public class controller extends javax.swing.JFrame {
static WirelessKeypad keypad;
/**
* Creates new form controller
*/
public controller() {
initComponents();
}
/**
* 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() {
jScrollPane1 = new javax.swing.JScrollPane();
mainDisplay = new javax.swing.JTextArea();
jPanel1 = new javax.swing.JPanel();
one = new javax.swing.JButton();
two = new javax.swing.JButton();
three = new javax.swing.JButton();
four = new javax.swing.JButton();
five = new javax.swing.JButton();
six = new javax.swing.JButton();
seven = new javax.swing.JButton();
eight = new javax.swing.JButton();
nine = new javax.swing.JButton();
zero = new javax.swing.JButton();
delete = new javax.swing.JButton();
enter = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
smokelvl = new javax.swing.JCheckBox();
waterLvl = new javax.swing.JCheckBox();
runTest = new javax.swing.JButton();
panic = new javax.swing.JCheckBox();
panel1 = new java.awt.Panel();
addMob = new javax.swing.JButton();
rmvMob = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
userInput = new javax.swing.JTextArea();
jLabel1 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
away = new javax.swing.JButton();
home = new javax.swing.JButton();
disarm = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
statuscheck = new javax.swing.JButton();
panicBtn = new javax.swing.JButton();
viewBtn = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(204, 230, 248));
setResizable(false);
mainDisplay.setColumns(20);
mainDisplay.setFont(new java.awt.Font("Monospaced", 0, 15)); // NOI18N
mainDisplay.setRows(5);
mainDisplay.setText("Welcome! \n");
jScrollPane1.setViewportView(mainDisplay);
jPanel1.setBackground(new java.awt.Color(102, 102, 102));
one.setText("1");
one.setMaximumSize(new java.awt.Dimension(40, 40));
one.setMinimumSize(new java.awt.Dimension(40, 40));
one.setPreferredSize(new java.awt.Dimension(40, 40));
one.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oneActionPerformed(evt);
}
});
two.setText("2");
two.setMaximumSize(new java.awt.Dimension(35, 35));
two.setMinimumSize(new java.awt.Dimension(35, 35));
two.setPreferredSize(new java.awt.Dimension(35, 35));
two.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
twoActionPerformed(evt);
}
});
three.setText("3");
three.setMaximumSize(new java.awt.Dimension(40, 40));
three.setMinimumSize(new java.awt.Dimension(40, 40));
three.setPreferredSize(new java.awt.Dimension(40, 40));
three.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
threeActionPerformed(evt);
}
});
four.setText("4");
four.setPreferredSize(new java.awt.Dimension(35, 35));
four.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fourActionPerformed(evt);
}
});
five.setText("5");
five.setPreferredSize(new java.awt.Dimension(35, 35));
five.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fiveActionPerformed(evt);
}
});
six.setText("6");
six.setPreferredSize(new java.awt.Dimension(35, 35));
six.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sixActionPerformed(evt);
}
});
seven.setText("7");
seven.setPreferredSize(new java.awt.Dimension(35, 35));
seven.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sevenActionPerformed(evt);
}
});
eight.setText("8");
eight.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
eightActionPerformed(evt);
}
});
nine.setText("9");
nine.setMaximumSize(new java.awt.Dimension(25, 25));
nine.setMinimumSize(new java.awt.Dimension(25, 25));
nine.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nineActionPerformed(evt);
}
});
zero.setText("0");
zero.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
zeroActionPerformed(evt);
}
});
delete.setText("X");
delete.setPreferredSize(new java.awt.Dimension(35, 35));
delete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
deleteActionPerformed(evt);
}
});
enter.setText("Enter");
enter.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
enterActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(one, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(two, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(three, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(0, 3, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(zero, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(seven, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE)
.addComponent(four, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(eight, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(nine, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(five, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(six, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(delete, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(17, 17, 17))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(enter, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(35, 35, 35))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(one, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(two, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(three, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(8, 8, 8)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(five, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(six, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(four, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(42, 42, 42)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(nine, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(eight, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(seven, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(zero, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(delete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(enter, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel2.setBackground(new java.awt.Color(102, 102, 102));
jPanel2.setEnabled(false);
smokelvl.setForeground(new java.awt.Color(255, 255, 255));
smokelvl.setText("set High Smoke Level");
smokelvl.setEnabled(false);
smokelvl.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
smokelvlActionPerformed(evt);
}
});
waterLvl.setForeground(new java.awt.Color(255, 255, 255));
waterLvl.setText("set High Water Level");
waterLvl.setEnabled(false);
waterLvl.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
waterLvlActionPerformed(evt);
}
});
runTest.setText("Run Test");
runTest.setEnabled(false);
runTest.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
runTestActionPerformed(evt);
}
});
panic.setForeground(new java.awt.Color(255, 255, 255));
panic.setText("Silent Mode : Panic Button");
panic.setEnabled(false);
panic.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
panicActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(16, 16, 16)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(waterLvl)
.addComponent(smokelvl))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(0, 17, Short.MAX_VALUE)
.addComponent(panic)))
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(52, 52, 52)
.addComponent(runTest, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(13, 13, 13)
.addComponent(waterLvl)
.addGap(18, 18, 18)
.addComponent(smokelvl)
.addGap(26, 26, 26)
.addComponent(panic)
.addGap(18, 18, 18)
.addComponent(runTest, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panel1.setBackground(new java.awt.Color(102, 102, 102));
addMob.setText("Add Phone Number");
addMob.setEnabled(false);
addMob.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addMobActionPerformed(evt);
}
});
rmvMob.setText("Remove Phone Number");
rmvMob.setEnabled(false);
rmvMob.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rmvMobActionPerformed(evt);
}
});
userInput.setColumns(20);
userInput.setFont(new java.awt.Font("Monospaced", 0, 15)); // NOI18N
userInput.setRows(5);
userInput.setMaximumSize(new java.awt.Dimension(100, 100));
jScrollPane2.setViewportView(userInput);
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("User Input");
javax.swing.GroupLayout panel1Layout = new javax.swing.GroupLayout(panel1);
panel1.setLayout(panel1Layout);
panel1Layout.setHorizontalGroup(
panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(rmvMob, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(addMob, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(37, 37, 37)))
.addGap(34, 34, 34))
);
panel1Layout.setVerticalGroup(
panel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(addMob, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(rmvMob, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel3.setBackground(new java.awt.Color(0, 204, 102));
away.setText("AWAY");
away.setEnabled(false);
away.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
awayActionPerformed(evt);
}
});
home.setText("HOME");
home.setEnabled(false);
home.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
homeActionPerformed(evt);
}
});
disarm.setText("DISARM");
disarm.setEnabled(false);
disarm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
disarmActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(away)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(home)
.addGap(18, 18, 18)
.addComponent(disarm)
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(away, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(home, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(disarm, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel4.setBackground(new java.awt.Color(0, 204, 102));
statuscheck.setText("Status Check");
statuscheck.setEnabled(false);
statuscheck.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
statuscheckActionPerformed(evt);
}
});
panicBtn.setText("Panc Button");
panicBtn.setEnabled(false);
panicBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
panicBtnActionPerformed(evt);
}
});
viewBtn.setText("View Camera");
viewBtn.setEnabled(false);
viewBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
viewBtnActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(viewBtn)
.addGap(18, 18, 18)
.addComponent(statuscheck)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(panicBtn)
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(statuscheck, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(panicBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(viewBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(41, 41, 41)
.addComponent(panel1, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(panel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void runTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runTestActionPerformed
// TODO add your handling code here:
wt.sendAlert();
mainDisplay.append("\n"+keypad.getAlert());
ss.sendAlert();
mainDisplay.append("\n"+keypad.getAlert());
}//GEN-LAST:event_runTestActionPerformed
private void disarmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_disarmActionPerformed
// TODO add your handling code here:
mainDisplay.append("\n"+keypad.setMode("deactivate"));
}//GEN-LAST:event_disarmActionPerformed
private void homeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_homeActionPerformed
// TODO add your handling code here:
mainDisplay.append("\n"+keypad.setMode("home"));
}//GEN-LAST:event_homeActionPerformed
private void panicBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_panicBtnActionPerformed
// TODO add your handling code here:
pbt.pressButton();
mainDisplay.append("\n"+keypad.getAlert());
}//GEN-LAST:event_panicBtnActionPerformed
private void statuscheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_statuscheckActionPerformed
// TODO add your handling code here:
if(userInput.getText().toString().equals(""))
mainDisplay.append("\n Please Enter device ID: ");
else{
String id = userInput.getText().toString();
mainDisplay.append("\nid is : " + id);
mainDisplay.append("\n" + keypad.checkStatus(id));
}
userInput.setText("");
}//GEN-LAST:event_statuscheckActionPerformed
private void awayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_awayActionPerformed
// TODO add your handling code here:
mainDisplay.append("\n"+keypad.setMode("away"));
}//GEN-LAST:event_awayActionPerformed
private void addMobActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addMobActionPerformed
// TODO add your handling code here:
String num = userInput.getText();
userInput.setText("");
mainDisplay.append("\n"+keypad.addMobileNo(num));
}//GEN-LAST:event_addMobActionPerformed
private void rmvMobActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rmvMobActionPerformed
// TODO add your handling code here:
String num = userInput.getText();
userInput.setText("");
mainDisplay.append("\n"+keypad.removeMobileNo(num));
}//GEN-LAST:event_rmvMobActionPerformed
private void panicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_panicActionPerformed
// TODO add your handling code here:
if(panic.isSelected())
mainDisplay.append("\n"+pbt.onSilentAlarmMode(true));
else
mainDisplay.append("\n"+pbt.onSilentAlarmMode(false));
}//GEN-LAST:event_panicActionPerformed
private void waterLvlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_waterLvlActionPerformed
// TODO add your handling code here:
if(waterLvl.isSelected()){
wt.setWaterLevel(51);
}else{
wt.setWaterLevel(0);
}
}//GEN-LAST:event_waterLvlActionPerformed
private void smokelvlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_smokelvlActionPerformed
// TODO add your handling code here:
if(smokelvl.isSelected()){
ss.setSmokeLevel(51);
}else{
ss.setSmokeLevel(0);
}
}//GEN-LAST:event_smokelvlActionPerformed
private void enterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enterActionPerformed
// TODO add your handling code here:
// String input = userInput.getText();
// userInput.setText("");
// if(keypad.checkPassword(input)){
// mainDisplay.append("\n"+"Corrent Password");
// }else{
// mainDisplay.append("\n"+"Wrong Password, Try Again");
// }
String input = userInput.getText();
userInput.setText("");
if (keypad.checkPassword(input)) {
mainDisplay.append("\n" + "Correct Password. Welcome Home!\n");
disarm.setEnabled(true);
away.setEnabled(true);
home.setEnabled(true);
statuscheck.setEnabled(true);
panicBtn.setEnabled(true);
runTest.setEnabled(true);
addMob.setEnabled(true);
rmvMob.setEnabled(true);
smokelvl.setEnabled(true);
waterLvl.setEnabled(true);
panic.setEnabled(true);
viewBtn.setEnabled(true);
} else {
mainDisplay.append("\n" + "Wrong Password, Try Again\n");
}
}//GEN-LAST:event_enterActionPerformed
private void deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteActionPerformed
// TODO add your handling code here:
// String str = userInput.getText();
//
// // Removing first and last character
// // of a string using substring() method
// str = str.substring(0, str.length() - 1);
// userInput.setText("");
// userInput.append(str);
String str = userInput.getText();
// Removing first and last character
// of a string using substring() method
if (!str.equals("")) {
str = str.substring(0, str.length() - 1);
userInput.setText("");
userInput.append(str);
}
// Return the modified string
}//GEN-LAST:event_deleteActionPerformed
private void zeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zeroActionPerformed
// TODO add your handling code here:
userInput.append(0+"");
}//GEN-LAST:event_zeroActionPerformed
private void nineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nineActionPerformed
// TODO add your handling code here:
userInput.append(9+"");
}//GEN-LAST:event_nineActionPerformed
private void eightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eightActionPerformed
// TODO add your handling code here:
userInput.append(8+"");
}//GEN-LAST:event_eightActionPerformed
private void sevenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sevenActionPerformed
// TODO add your handling code here:
userInput.append(7+"");
}//GEN-LAST:event_sevenActionPerformed
private void sixActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sixActionPerformed
// TODO add your handling code here:
userInput.append(6+"");
}//GEN-LAST:event_sixActionPerformed
private void fiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fiveActionPerformed
// TODO add your handling code here:
userInput.append(5+"");
}//GEN-LAST:event_fiveActionPerformed
private void fourActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fourActionPerformed
// TODO add your handling code here:
userInput.append(4+"");
}//GEN-LAST:event_fourActionPerformed
private void threeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_threeActionPerformed
// TODO add your handling code here:
userInput.append(3+"");
}//GEN-LAST:event_threeActionPerformed
private void twoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_twoActionPerformed
// TODO add your handling code here:
userInput.append(2+"");
}//GEN-LAST:event_twoActionPerformed
private void oneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_oneActionPerformed
// TODO add your handling code here:
userInput.append(1+"");
}//GEN-LAST:event_oneActionPerformed
private void viewBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewBtnActionPerformed
// TODO add your handling code here:
new cameraView().setVisible(true);
}//GEN-LAST:event_viewBtnActionPerformed
static PanicButton pbt;
static WaterSensor wt;
static SmokeDetector ss;
static SecurityCamera scam;
/**
* @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(controller.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(controller.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(controller.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(controller.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
keypad = new WirelessKeypad();
wt = new WaterSensor();
// System.out.println("water sensor ID" + wt.deviceID);
pbt = new PanicButton();
ss = new SmokeDetector();
scam = new SecurityCamera();
List<SecurityDevice> sd = new ArrayList<>();
sd.add(wt);
sd.add(pbt);
sd.add(ss);
sd.add(scam);
// for(SecurityDevice d : sd)
// System.out.println("\nID : " + d.deviceID);
BaseStation base = new BaseStation(sd);
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new controller().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addMob;
private javax.swing.JButton away;
private javax.swing.JButton delete;
private javax.swing.JButton disarm;
private javax.swing.JButton eight;
private javax.swing.JButton enter;
private javax.swing.JButton five;
private javax.swing.JButton four;
private javax.swing.JButton home;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextArea mainDisplay;
private javax.swing.JButton nine;
private javax.swing.JButton one;
private java.awt.Panel panel1;
private javax.swing.JCheckBox panic;
private javax.swing.JButton panicBtn;
private javax.swing.JButton rmvMob;
private javax.swing.JButton runTest;
private javax.swing.JButton seven;
private javax.swing.JButton six;
private javax.swing.JCheckBox smokelvl;
private javax.swing.JButton statuscheck;
private javax.swing.JButton three;
private javax.swing.JButton two;
private javax.swing.JTextArea userInput;
private javax.swing.JButton viewBtn;
private javax.swing.JCheckBox waterLvl;
private javax.swing.JButton zero;
// End of variables declaration//GEN-END:variables
}