-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInterface.java
809 lines (713 loc) · 44.1 KB
/
Interface.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
package roundrobinsimulation;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
public class Interface extends javax.swing.JFrame {
RoundRobin rr;
public Interface() {
initComponents();
this.setTitle("Round Robin Simulation");
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int initalHeight = screenSize.height * 2 / 3;
int initalWidth = screenSize.width * 2 / 3;
System.out.println(initalHeight);
System.out.println(initalWidth);
//setPreferredSize(new Dimension(initalWidth,initalHeight));
//this.jPanel2 = new JPanel();
//this.jPanel2.setL
this.jPanel2.setPreferredSize(new Dimension(0,0));
//this.setPreferredSize(new Dimension(initalWidth,initalHeight));
this.jPanel2.setVisible(false);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField();
jTextField7 = new javax.swing.JTextField();
jTextField8 = new javax.swing.JTextField();
jTextField9 = new javax.swing.JTextField();
jTextField10 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel38 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jLabel21 = new javax.swing.JLabel();
jLabel22 = new javax.swing.JLabel();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
jLabel25 = new javax.swing.JLabel();
jLabel26 = new javax.swing.JLabel();
jLabel27 = new javax.swing.JLabel();
jLabel28 = new javax.swing.JLabel();
jLabel29 = new javax.swing.JLabel();
jLabel30 = new javax.swing.JLabel();
jLabel31 = new javax.swing.JLabel();
jLabel32 = new javax.swing.JLabel();
jLabel33 = new javax.swing.JLabel();
jLabel34 = new javax.swing.JLabel();
jLabel35 = new javax.swing.JLabel();
jLabel36 = new javax.swing.JLabel();
jLabel37 = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(204, 204, 255));
jPanel1.setBackground(new java.awt.Color(204, 204, 255));
jLabel1.setFont(new java.awt.Font("Elephant", 0, 28)); // NOI18N
jLabel1.setText("Round Robin Scheduling Algorithm Simulation");
jLabel2.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel2.setText("Process 1");
jLabel7.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel7.setText("Process 2");
jLabel8.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel8.setText("Process 3");
jLabel9.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel9.setText("Process 4");
jLabel10.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel10.setText("Process 5");
jLabel11.setFont(new java.awt.Font("Elephant", 1, 22)); // NOI18N
jLabel11.setText("Enter Process Details");
jLabel11.setToolTipText("");
jTextField1.setBackground(new java.awt.Color(255, 255, 255));
jTextField1.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField1.setForeground(new java.awt.Color(51, 0, 51));
jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField2.setBackground(new java.awt.Color(255, 255, 255));
jTextField2.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField2.setForeground(new java.awt.Color(51, 0, 51));
jTextField2.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField2.setToolTipText("");
jTextField3.setBackground(new java.awt.Color(255, 255, 255));
jTextField3.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField3.setForeground(new java.awt.Color(51, 0, 51));
jTextField3.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField4.setBackground(new java.awt.Color(255, 255, 255));
jTextField4.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField4.setForeground(new java.awt.Color(51, 0, 51));
jTextField4.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField5.setBackground(new java.awt.Color(255, 255, 255));
jTextField5.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField5.setForeground(new java.awt.Color(51, 0, 51));
jTextField5.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField6.setBackground(new java.awt.Color(255, 255, 255));
jTextField6.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField6.setForeground(new java.awt.Color(51, 0, 51));
jTextField6.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField7.setBackground(new java.awt.Color(255, 255, 255));
jTextField7.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField7.setForeground(new java.awt.Color(51, 0, 51));
jTextField7.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField8.setBackground(new java.awt.Color(255, 255, 255));
jTextField8.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField8.setForeground(new java.awt.Color(51, 0, 51));
jTextField8.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField9.setBackground(new java.awt.Color(255, 255, 255));
jTextField9.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField9.setForeground(new java.awt.Color(51, 0, 51));
jTextField9.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField10.setBackground(new java.awt.Color(255, 255, 255));
jTextField10.setFont(new java.awt.Font("Elephant", 0, 18)); // NOI18N
jTextField10.setForeground(new java.awt.Color(51, 0, 51));
jTextField10.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jLabel3.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel3.setText("Arrival Time");
jLabel4.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel4.setText("Burst Time");
jLabel12.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel12.setText("Automatically Setted Time Quantum");
jButton1.setBackground(new java.awt.Color(153, 153, 255));
jButton1.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jButton1.setText("CLEAR");
jButton1.setToolTipText("");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton3.setBackground(new java.awt.Color(153, 153, 255));
jButton3.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jButton3.setText("TEST");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jLabel38.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel38.setForeground(new java.awt.Color(255, 255, 255));
jLabel38.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel38.setText("0");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(154, 154, 154)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(131, 131, 131)
.addComponent(jLabel11))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7)
.addComponent(jLabel2)
.addComponent(jLabel8)
.addComponent(jLabel9))
.addComponent(jLabel10))
.addGap(53, 53, 53)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField1)
.addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 167, Short.MAX_VALUE)
.addComponent(jTextField3)
.addComponent(jTextField4)
.addComponent(jTextField5))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextField7, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField8, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField9, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField10, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField6, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel12)
.addGap(26, 26, 26)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(37, 37, 37)
.addComponent(jButton3))
.addComponent(jLabel38, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(328, 328, 328)
.addComponent(jLabel3)
.addGap(76, 76, 76)
.addComponent(jLabel4))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(jLabel1)))
.addContainerGap(204, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel11)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(jLabel38))
.addGap(39, 39, 39)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton3))
.addContainerGap(21, Short.MAX_VALUE))
);
jPanel2.setBackground(new java.awt.Color(204, 204, 255));
jLabel5.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel5.setText("Process 1");
jLabel6.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel6.setText("Process 2");
jLabel13.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel13.setText("Process 3");
jLabel14.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel14.setText("Process 4");
jLabel15.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel15.setText("Process 5");
jLabel16.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel16.setText("Completed Time");
jLabel17.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel17.setText("Waiting Time");
jLabel18.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel18.setText("Turnaround Time");
jLabel19.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel19.setForeground(new java.awt.Color(255, 255, 255));
jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel19.setText("1");
jLabel20.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel20.setForeground(new java.awt.Color(255, 255, 255));
jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel20.setText("2");
jLabel21.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel21.setForeground(new java.awt.Color(255, 255, 255));
jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel21.setText("2");
jLabel22.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel22.setForeground(new java.awt.Color(255, 255, 255));
jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel22.setText("1");
jLabel23.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel23.setForeground(new java.awt.Color(255, 255, 255));
jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel23.setText("1");
jLabel24.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel24.setForeground(new java.awt.Color(255, 255, 255));
jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel24.setText("1");
jLabel24.setToolTipText("");
jLabel25.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel25.setForeground(new java.awt.Color(255, 255, 255));
jLabel25.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel25.setText("1");
jLabel26.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel26.setForeground(new java.awt.Color(255, 255, 255));
jLabel26.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel26.setText("1");
jLabel27.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel27.setForeground(new java.awt.Color(255, 255, 255));
jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel27.setText("1");
jLabel28.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel28.setForeground(new java.awt.Color(255, 255, 255));
jLabel28.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel28.setText("1");
jLabel29.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel29.setForeground(new java.awt.Color(255, 255, 255));
jLabel29.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel29.setText("1");
jLabel30.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel30.setForeground(new java.awt.Color(255, 255, 255));
jLabel30.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel30.setText("1");
jLabel31.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel31.setForeground(new java.awt.Color(255, 255, 255));
jLabel31.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel31.setText("1");
jLabel32.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel32.setForeground(new java.awt.Color(255, 255, 255));
jLabel32.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel32.setText("1");
jLabel33.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel33.setForeground(new java.awt.Color(255, 255, 255));
jLabel33.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel33.setText("1");
jLabel34.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel34.setText("Avergage Turnaround Time");
jLabel35.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel35.setText("Average Waiting Tiime");
jLabel36.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel36.setForeground(new java.awt.Color(255, 255, 255));
jLabel36.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel36.setText("1");
jLabel37.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jLabel37.setForeground(new java.awt.Color(255, 255, 255));
jLabel37.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel37.setText("1");
jButton4.setBackground(new java.awt.Color(153, 153, 255));
jButton4.setFont(new java.awt.Font("Elephant", 1, 18)); // NOI18N
jButton4.setText("SHOW THE GANTT CHART");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(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(100, 100, 100)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel15)
.addComponent(jLabel14)
.addComponent(jLabel13)
.addComponent(jLabel6)
.addComponent(jLabel5))
.addGap(35, 35, 35)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel16))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addComponent(jLabel17)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel18))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel26, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel29, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel33, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel32, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
.addComponent(jLabel30, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel27, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel31, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
.addComponent(jLabel28, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(205, 205, 205)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton4)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel34)
.addComponent(jLabel35))
.addGap(35, 35, 35)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel36, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
.addComponent(jLabel37, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel16)
.addComponent(jLabel17)
.addComponent(jLabel18))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel19)
.addComponent(jLabel20)
.addComponent(jLabel21))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel22)
.addComponent(jLabel23)
.addComponent(jLabel24))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(jLabel26)
.addComponent(jLabel27)
.addComponent(jLabel25))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(jLabel29)
.addComponent(jLabel30)
.addComponent(jLabel28))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel15)
.addComponent(jLabel33)
.addComponent(jLabel32)
.addComponent(jLabel31))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel35)
.addComponent(jLabel36))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel34)
.addComponent(jLabel37))
.addGap(53, 53, 53)
.addComponent(jButton4)
.addContainerGap(85, 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()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
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)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
this.jPanel2.setVisible(false);
this.jTextField1.setText("");
this.jTextField2.setText("");
this.jTextField3.setText("");
this.jTextField4.setText("");
this.jTextField5.setText("");
this.jTextField6.setText("");
this.jTextField7.setText("");
this.jTextField8.setText("");
this.jTextField9.setText("");
this.jTextField10.setText("");
this.jLabel38.setText("0");
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
try{
int[] checkNumbers = new int[10];
checkNumbers[0] = Integer.parseInt(this.jTextField1.getText());
checkNumbers[1] = Integer.parseInt(this.jTextField2.getText());
checkNumbers[2] = Integer.parseInt(this.jTextField3.getText());
checkNumbers[3] = Integer.parseInt(this.jTextField4.getText());
checkNumbers[4] = Integer.parseInt(this.jTextField5.getText());
checkNumbers[5] = Integer.parseInt(this.jTextField6.getText());
checkNumbers[6] = Integer.parseInt(this.jTextField7.getText());
checkNumbers[7] = Integer.parseInt(this.jTextField8.getText());
checkNumbers[8] = Integer.parseInt(this.jTextField9.getText());
checkNumbers[9] = Integer.parseInt(this.jTextField10.getText());
boolean tempCheck = true;
for (int i=0;i<10;i++){
if (checkNumbers[i]<0){
tempCheck = false;
break;
}
}
if(tempCheck){
Process p1 = new Process("Process1",checkNumbers[0],checkNumbers[5]);
Process p2 = new Process("Process2",checkNumbers[1],checkNumbers[6]);
Process p3 = new Process("Process3",checkNumbers[2],checkNumbers[7]);
Process p4 = new Process("Process4",checkNumbers[3],checkNumbers[8]);
Process p5 = new Process("Process5",checkNumbers[4],checkNumbers[9]);
ArrayList<Process> processList = new ArrayList<>(Arrays.asList(p1,p2,p3,p4,p5));
this.rr = new RoundRobin(processList);
processList = this.rr.getCalculate();
p1 = processList.get(0);
String ct1 = Integer.toString(p1.getCompletedTime());
String wt1 = Integer.toString(p1.getWaitingTime());
String tat1 = Integer.toString(p1.getTurnAroundTime());
this.jLabel5.setText(p1.getName());
this.jLabel19.setText(ct1);
this.jLabel20.setText(wt1);
this.jLabel21.setText(tat1);
p2 = processList.get(1);
String ct2 = Integer.toString(p2.getCompletedTime());
String wt2 = Integer.toString(p2.getWaitingTime());
String tat2 = Integer.toString(p2.getTurnAroundTime());
this.jLabel6.setText(p2.getName());
this.jLabel22.setText(ct2);
this.jLabel23.setText(wt2);
this.jLabel24.setText(tat2);
p3 = processList.get(2);
String ct3 = Integer.toString(p3.getCompletedTime());
String wt3 = Integer.toString(p3.getWaitingTime());
String tat3 = Integer.toString(p3.getTurnAroundTime());
this.jLabel13.setText(p3.getName());
this.jLabel26.setText(ct3);
this.jLabel27.setText(wt3);
this.jLabel25.setText(tat3);
p4 = processList.get(3);
String ct4 = Integer.toString(p4.getCompletedTime());
String wt4 = Integer.toString(p4.getWaitingTime());
String tat4 = Integer.toString(p4.getTurnAroundTime());
// checkNumbers[9] = Integer.parseInt(ct4);
// checkNumbers[10] = Integer.parseInt(wt4);
// checkNumbers[11] = Integer.parseInt(tat4);
this.jLabel14.setText(p4.getName());
this.jLabel29.setText(ct4);
this.jLabel30.setText(wt4);
this.jLabel28.setText(tat4);
p5 = processList.get(4);
String ct5 = Integer.toString(p5.getCompletedTime());
String wt5 = Integer.toString(p5.getWaitingTime());
String tat5 = Integer.toString(p5.getTurnAroundTime());
this.jLabel15.setText(p5.getName());
this.jLabel33.setText(ct5);
this.jLabel32.setText(wt5);
this.jLabel31.setText(tat5);
double awt = (Double.parseDouble(wt1) + Double.parseDouble(wt2) + Double.parseDouble(wt3) + Double.parseDouble(wt4) + Double.parseDouble(wt5))/5;
//float tempAWT = (float)Math.round(awt*100)/100;
//String.format("%.2f", i2)
String awts = String.format("%.2f", awt);
this.jLabel36.setText(awts);
double atat = (Double.parseDouble(tat1) + Double.parseDouble(tat2) + Double.parseDouble(tat3) + Double.parseDouble(tat4) + Double.parseDouble(tat5))/5;
//float tempATAT = (float)Math.round(atat*100)/100;
String tats = String.format("%.2f", atat);
this.jLabel37.setText(tats);
this.jLabel38.setText(Integer.toString(this.rr.getTimeQuantum()));
this.jPanel2.setVisible(true);
}
else{
JOptionPane.showMessageDialog(rootPane, "Please enter postive values only!");
}
}
catch(NumberFormatException ex){
JOptionPane.showMessageDialog(rootPane, "Please Enter all the values to complete the calculation!");
}
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
//show the gantt chart
ArrayList<String[]> temp = this.rr.getTiminigDetails();
System.out.println(temp.size());
GanttChart example = new GanttChart("Round Robin Simulation",temp);
example.setSize(800, 400);
example.setLocationRelativeTo(null);
example.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
example.setVisible(true);
URL iconURL = getClass().getResource("robin.png");
// iconURL is null when not found
ImageIcon icon = new ImageIcon(iconURL);
example.setIconImage(icon.getImage());
}//GEN-LAST:event_jButton4ActionPerformed
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(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Interface.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Interface.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() {
JFrame temp = new Interface();
URL iconURL = getClass().getResource("robin.png");
// iconURL is null when not found
ImageIcon icon = new ImageIcon(iconURL);
temp.setIconImage(icon.getImage());
//temp.setLocationRelativeTo(null);
temp.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel28;
private javax.swing.JLabel jLabel29;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel30;
private javax.swing.JLabel jLabel31;
private javax.swing.JLabel jLabel32;
private javax.swing.JLabel jLabel33;
private javax.swing.JLabel jLabel34;
private javax.swing.JLabel jLabel35;
private javax.swing.JLabel jLabel36;
private javax.swing.JLabel jLabel37;
private javax.swing.JLabel jLabel38;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField10;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
private javax.swing.JTextField jTextField7;
private javax.swing.JTextField jTextField8;
private javax.swing.JTextField jTextField9;
// End of variables declaration//GEN-END:variables
}