-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormFrameFile.java
More file actions
709 lines (633 loc) · 18.1 KB
/
Copy pathFormFrameFile.java
File metadata and controls
709 lines (633 loc) · 18.1 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
package Projekt;
import java.io.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
class FormDeleteFrame extends Frame implements ActionListener{ //form-delete frame
String str;
Label deleteL, deleteOutL;
Button deleteB;
TextField deleteFileTf, deleteOutTf;
FormDeleteFrame(String s) {
super(s);
setLayout(null);
setSize(925,1050); //width - height
setFont(new Font("Helvetica",Font.BOLD,40));
setBackground(Color.black);
setForeground(Color.white);
//delete label
deleteL = new Label("★ Enter ID To Delete Form:-");
deleteL.setBounds(100, 220, 550, 50);
deleteFileTf = new TextField();
deleteFileTf.setForeground(Color.black);
deleteFileTf.setBounds(100, 300, 650, 60);
//delete button
deleteB = new Button("DELETE");
deleteB.setForeground(Color.black);
deleteB.setBounds(100, 400, 300, 50);
//deleted successfully
deleteOutL = new Label("★ Form Status:-");
deleteOutL.setBounds(100, 570, 550, 50);
deleteOutTf = new TextField();
deleteOutTf.setBackground(Color.black);
deleteOutTf.setEditable(false);
//here color of status
deleteOutTf.setBounds(100, 650, 650, 60);
add(deleteL);
add(deleteFileTf);
add(deleteB);
add(deleteOutL);
add(deleteOutTf);
deleteB.addActionListener(this);
//close
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == deleteB) {
str = deleteFileTf.getText();
File f = new File("D:\\Java Programs\\Java Eclipse\\EclipsePrograms\\IO files\\"+str+".txt");
if(f.exists() == true) {
f.delete();
deleteOutTf.setBackground(Color.black);
deleteOutTf.setForeground(Color.GREEN);
deleteOutTf.setText("Form Deleted");
}
else if(f.exists() == false) {
deleteOutTf.setBackground(Color.black);
deleteOutTf.setForeground(Color.red);
deleteOutTf.setText("File Does Not Exist");
}
}
}
}
class FormSearchFrame extends Frame implements ActionListener{ //form-search frame
//file-->
File fSearch;
//frame
TextField searchTf, searchOutTf;
Label searchL, searchOutL;
Button searchB;
FormSearchFrame(String s){
super(s);
setLayout(null);
setSize(925,1050); //width - height
setFont(new Font("Helvetica",Font.BOLD,40));
setBackground(Color.black);
setForeground(Color.white);
//search
searchL = new Label("★ Search Form By ID:-");
searchL.setBounds(100, 220, 550, 50);
searchTf = new TextField();
searchTf.setForeground(Color.black);
searchTf.setBounds(100, 300, 650, 60);
//search btn
searchB = new Button("SEARCH");
searchB.setForeground(Color.black);
searchB.setBounds(100, 400, 300, 50);
//searchOutL
searchOutL = new Label("★ Form Status:-");
searchOutL.setBounds(100, 570, 550, 50);
searchOutTf = new TextField();
searchOutTf.setBackground(Color.black);
searchOutTf.setEditable(false);
//here color of status
searchOutTf.setBounds(100, 650, 650, 60);
add(searchL);
add(searchTf);
add(searchB);
add(searchOutL);
add(searchOutTf);
searchB.addActionListener(this);
//close
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
String str;
str = searchTf.getText();
fSearch = new File("D:\\Java Programs\\Java Eclipse\\EclipsePrograms\\IO files\\"+str+".txt");
//************************************status color
if(fSearch.exists() == true) {
searchOutTf.setBackground(Color.black);
searchOutTf.setForeground(Color.GREEN);
}
else {
searchOutTf.setBackground(Color.black);
searchOutTf.setForeground(Color.red);
}
//**************************************status color-end
if(e.getSource() == searchB) {
if(fSearch.exists() == true) {
searchOutTf.setText("File Available");
}
else if(fSearch.exists() == false) {
searchOutTf.setText("File Unavailable");
}
}
}
}
class FormFrame extends Frame implements ActionListener { //form fill frame
//File-->
File f;
FileOutputStream fos;
String str;
char[] ch;
//Frame-->
Button submitB;
Choice deptCh, admYrCh, secCh, genderCh;
Label hL,emailL, selectDeptL, fullNameL, admYrL, secL, rollL, genderL, mobileL, permanentL;
TextField emailTf, fullNameTf, rollTf, mobileTf, permanentTf, savedSuccessTf;
FormFrame(String s) throws Exception {
super(s);
setLayout(null);
setSize(925,1050); //width,height
//headline
hL = new Label("Provisional Admission Form");
hL.setFont(new Font("Helvetica",Font.BOLD,50));
hL.setBounds(100, 150, 900, 50);
setFont(new Font("Helvetica",Font.PLAIN,20));
//email address--> align
emailL = new Label("★ Email address:-");
emailL.setBounds(100, 300, 200, 30);
emailTf = new TextField();
emailTf.setBounds(300, 300, 480, 30);
//Select the Department *--->align
selectDeptL = new Label("★ Select the Department:-");
selectDeptL.setBounds(100, 350, 250, 50);
deptCh = new Choice();
deptCh.setBounds(350, 360, 430, 50);
deptCh.add("---select---");
deptCh.add("Computer Science Engineering");
deptCh.add("Mechanical Engineering");
deptCh.add("Information Technology");
deptCh.add("Electronics & Telecommunication Engineering");
deptCh.add("Civil Engineering");
deptCh.add("MBA");
deptCh.add("MCA");
//Full Name:-->align
fullNameL = new Label("★ Full Name:-");
fullNameL.setBounds(100, 420, 150, 30);
fullNameTf = new TextField();
fullNameTf.setBounds(250, 420, 530, 30);
//Seeking Provisional Admission to *:-->align
admYrL = new Label("★ Seeking Provisional Admission to:-");
admYrL.setBounds(100, 480, 350, 30);
admYrCh = new Choice();
admYrCh.setBounds(450, 480, 330, 30);
admYrCh.add("---select---");
admYrCh.add("B.E II Year");
admYrCh.add("B.E III Year");
admYrCh.add("B.E IV Year");
admYrCh.add("MCA II Year");
admYrCh.add("MCA III Year");
admYrCh.add("MBA II Year");
admYrCh.add("M.E");
//Section *-->align
secL = new Label("★ Section:-");
secL.setBounds(100, 530, 130, 30);
secCh = new Choice();
secCh.setBounds(230, 530, 550, 30);
secCh.add("---select---");
secCh.add("Section A");
secCh.add("Section B");
secCh.add("Secton C (Second Shift)");
secCh.add("Other (MCA)");
//Roll No *-->align
rollL = new Label("★ Roll No:-");
rollL.setBounds(100, 580, 130, 30);
rollTf = new TextField();
rollTf.setBounds(230, 580, 550, 30);
//Gender:-->align
genderL = new Label("★ Gender:-");
genderL.setBounds(100, 640, 130, 30);
genderCh = new Choice();
genderCh.setBounds(230, 640, 550, 30);
genderCh.add("---select---");
genderCh.add("Male");
genderCh.add("Female");
//Student Mobile No *--> align
mobileL = new Label("★ Student Mobile No:-");
mobileL.setBounds(100, 690, 230, 30);
mobileTf = new TextField("+91 ");
mobileTf.setBounds(330, 690, 450, 30);
//Permanent Address *-->align
permanentL = new Label("★ Permanent Address:-");
permanentL.setBounds(100, 740, 230, 30);
permanentTf = new TextField();
permanentTf.setBounds(330, 740, 450, 30);
//Submit Button
submitB = new Button("SUBMIT");
submitB.setBounds(360, 850, 200, 60);
//TODO: complete form --> design it --> file handling --> done
//saved-successTf
savedSuccessTf = new TextField(" ★ All Fields Mandatory");
savedSuccessTf.setEditable(false);
savedSuccessTf.setBounds(335, 950, 250, 35);
//
add(hL);
add(emailL);//
add(emailTf);//
add(selectDeptL);//
add(deptCh); //
add(fullNameL);//
add(fullNameTf);//
add(admYrL);//
add(admYrCh);//
add(secL);//
add(secCh);//
add(rollL);//
add(rollTf);//
add(genderL);//
add(genderCh);//
add(mobileL);//
add(mobileTf);//
add(permanentL);//
add(permanentTf);//
add(submitB);//
add(savedSuccessTf);
submitB.addActionListener(this);
//********************************************************************************************************close
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
String sureRoll;
sureRoll = rollTf.getText();
f = new File("D:\\Java Programs\\Java Eclipse\\EclipsePrograms\\IO files\\"+sureRoll+".txt");
try {
fos = new FileOutputStream(f, false);
} catch (FileNotFoundException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
// TODO Auto-generated method stub
if(e.getSource() == submitB) {
//email Label
str = emailL.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//email
str = emailTf.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//space1
try {
fos.write('\n');
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//selectDeptL
str = selectDeptL.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//deptCh
str = deptCh.getSelectedItem();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//space2
try {
fos.write('\n');
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//fullNameL
str = fullNameL.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//fullNameTf
str = fullNameTf.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//space3
try {
fos.write('\n');
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//admYrL
str = admYrL.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//admYrCh
str = admYrCh.getSelectedItem();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//space4
try {
fos.write('\n');
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//secL
str = secL.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//secCh
str = secCh.getSelectedItem();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//space5
try {
fos.write('\n');
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//rollL
str = rollL.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//rollTf
str = rollTf.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//space6
try {
fos.write('\n');
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//genderL
str = genderL.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//genderCh
str = genderCh.getSelectedItem();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//space7
try {
fos.write('\n');
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//mobileL
str = mobileL.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//mobileTf
str = mobileTf.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//space8
try {
fos.write('\n');
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//permanentL
str = permanentL.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//permanentTf
str = permanentTf.getText();
ch = str.toCharArray();
for(int i=0; i<str.length(); i++) {
try {
fos.write(ch[i]);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
//space9
try {
fos.write('\n');
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//saved success
savedSuccessTf.setText(" ★ Successfully Saved");
}//end if(getSource() == submit)m
}
}
//Applet---------------->
public class FormFrameFile extends Applet implements ActionListener { //applet
//frame
FormFrame ff;
FormSearchFrame fsf;
FormDeleteFrame fdf;
TextArea ta;
Label l1, l2;
Button FormBtn, SearchBtn, DeleteBtn, UpdateBtn;
public void init() {
setLayout(null);
setSize(1850, 1050);
setBackground(Color.black);
try {
ff = new FormFrame("Admission Form"); //fill form cons
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fsf = new FormSearchFrame("Form: Search Form"); //search form cons
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fdf = new FormDeleteFrame("Form: Delete Form"); //delete form cons
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Applet contents----------------------------------->
l1 = new Label("Prof. Ram Meghe Institute of Technology & Research");
l1.setFont(new Font("Helvetica",Font.BOLD,50));
l1.setForeground(Color.white);
l1.setBounds(320, 50, 1600, 80);
l2 = new Label("Provisional Admission Form (Only for Regular Students)");
l2.setFont(new Font("Helvetica",Font.BOLD,40));
l2.setForeground(Color.red);
l2.setBounds(430, 150, 1100, 80);
ta = new TextArea("\n The students who have filled and submitted\n the Summer 2020 SGBAU Examination form\n are only eligible to fill the Provisional\n Admission Form for the Admission to the\n Higher Class.\n\n Note:- Your details will get stored in a file\n (File Name is your Roll No.)",8,40,TextArea.SCROLLBARS_NONE);
ta.setFont(new Font("Helvetica",Font.BOLD,25));
ta.setBackground(Color.black);
ta.setForeground(Color.white);
ta.setEditable(false);
ta.setBounds(660, 300, 560, 300);
//button-form applet
FormBtn = new Button("Fill Form");
FormBtn.setFont(new Font("Helvetica",Font.BOLD,30));
FormBtn.setBounds(660, 700, 200, 40);
//button-search
SearchBtn = new Button("Search Form");
SearchBtn.setFont(new Font("Helvetica",Font.BOLD,30));
SearchBtn.setBounds(1020, 700, 200, 40);
//button-delete
DeleteBtn = new Button("Delete Form");
DeleteBtn.setFont(new Font("Helvetica",Font.BOLD,30));
DeleteBtn.setBounds(660, 800, 200, 40);
//button-update
UpdateBtn = new Button("Update Form");
UpdateBtn.setFont(new Font("Helvetica",Font.BOLD,30));
UpdateBtn.setBounds(1020, 800, 200, 40);
add(l1);
add(l2);
add(ta);
add(FormBtn);
add(SearchBtn);
add(DeleteBtn);
add(UpdateBtn);
//registration
FormBtn.addActionListener(this);
SearchBtn.addActionListener(this);
DeleteBtn.addActionListener(this);
UpdateBtn.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == FormBtn) {
ff.setVisible(true); //form fill
}
else if(e.getSource() == SearchBtn) {
fsf.setVisible(true); //form search
}
else if(e.getSource() == DeleteBtn) {
fdf.setVisible(true); //form delete
}
}
}