-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormFrameFile.java
1652 lines (1415 loc) · 41 KB
/
FormFrameFile.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
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package Projekt;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
*
* Section:- Dialog Box
*
*
*/
class filenotfound1
{
filenotfound1()
{
/*
*
* Form doesn't exists!
*
*/
//pop-up: Class JOptionPane
JOptionPane.showMessageDialog(null,"Form Doesn't Exists!");
}
}
class succesful_written1
{
succesful_written1()
{
/*
*
* Form saved successfully!
*
*/
//pop-up: Class JOptionPane
JOptionPane.showMessageDialog(null,"Saved Successfully!");
}
}
//Wrong EMail
class popupWrongEmail1
{
/*
*
* check email: @/./com if not Invalid!
*
*/
popupWrongEmail1()
{ //pop-up: Class JOptionPane
JOptionPane.showMessageDialog(null,"Invalid Email Address!");
}
}
//Wrong empty information
class popupEmptyInformation1
{
/*
*
* Empty Text Fields!
*
*/
popupEmptyInformation1()
{
//pop-up: Class JOptionPane
JOptionPane.showMessageDialog(null,"Fill Empty Field/Fields!");
}
}//invalid mobile
class popupInvalidMobile1// extends Frame
{
/*
*
*
* 10 digits compulsory or invalid number
*
*/
popupInvalidMobile1()
{
JOptionPane.showMessageDialog(null,"Invalid Mobile Number!");
}
}
class FileExists1
{
/*
*
* Form Exists with same id!
*
*/
FileExists1()
{ //pop-up: Class JOptionPane
JOptionPane.showMessageDialog(null,"Form Already Exists!");
}
}
/*
*
* End:- Dialog Box
*
*
*/
class View_Forms extends Frame implements ActionListener{ // View Forms #1
Button viewB;
TextArea ta;
File file_directory;
View_Forms(String s) throws Exception {
super(s);
setLayout(null);
setSize(925,1050); //width,height
setFont(new Font("serif",Font.BOLD,30));
setBackground(Color.black);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
}
});
ta = new TextArea();
ta.setBounds(200, 200, 500, 500);
ta.setEditable(false);
ta.setBackground(Color.black);
ta.setForeground(Color.white);
ta.setVisible(false);
add(ta);
viewB = new Button("VIEW");
viewB.setBounds(200, 100, 500, 50);
add(viewB);
viewB.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
file_directory = new File("D:\\Java Programs\\Java Eclipse\\EclipsePrograms\\IO files");
//List of all files and directories
String contents[] = file_directory.list();
if(e.getSource() == viewB) {
ta.setVisible(true);
for(int i=0; i<contents.length; i++) {
ta.append(contents[i]+"\n");
}
}
}
}
class Update_Info extends Frame implements ActionListener//,ItemListener //update information ##3
{
String email, dept, fname, adm, sec, roll, gender, mobile, address;
Button submitB;
Choice deptCh, admYrCh, secCh, genderCh;
Label hL,emailL, selectDeptL, fullNameL, admYrL, secL, rollL, genderL, mobileL, permanentL;
TextField emailTf, fullNameTf, rollTf, mobileT, mobileTf, permanentTf, savedSuccessTf;
String is_email_valid="no";
String filemain;
File change_data;
/*
* dialog box objects
*/
popupWrongEmail1 emailpopup;
popupEmptyInformation1 emptypopup;
popupInvalidMobile1 InvalidMobPop;
// FileExists1 file;
succesful_written1 sw;
Update_Info(int bemail, int bdept, int bfname, int badm, int bsec, int broll, int bgender, int bmobile, int baddress, String framename, String file_name) throws Exception {
// TODO Auto-generated constructor stub
super("Re-Submit Form "+file_name+".txt");
setLayout(null);
setSize(925,1050); //width,height
filemain = file_name;
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
}
});
//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("");
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("");
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("");
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("");
genderCh.add("Male");
genderCh.add("Female");
//Student Mobile No *--> align
mobileL = new Label("★ Student Mobile No:-");
mobileL.setBounds(100, 690, 230, 30);
mobileT = new TextField("+91"); //+91
mobileT.setBounds(330, 690, 50, 30); //+91
mobileT.setEditable(false);
mobileTf = new TextField();
mobileTf.setBounds(380, 690, 400, 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.setFont(new Font("serif",Font.BOLD,30));
submitB.setBounds(325, 850, 275, 50);
//saved-successTf
savedSuccessTf = new TextField(" ★ All Fields Are Mandatory");
savedSuccessTf.setEditable(false);
savedSuccessTf.setBounds(325, 950, 275, 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(mobileT);
add(mobileTf);//
add(permanentL);//
add(permanentTf);//
add(submitB);//
add(savedSuccessTf);
submitB.addActionListener(this);
//setting textfields to editable
//true or false
if(bemail == 1) {
emailTf.setEditable(true);
}else {
emailTf.setEditable(false);
}
if(bdept == 1) {
deptCh.setEnabled(true);
}else {
deptCh.setEnabled(false);
}
if(bfname == 1) {
fullNameTf.setEditable(true);
}else {
fullNameTf.setEditable(false);
}
if(badm == 1) {
admYrCh.setEnabled(true);
}else {
admYrCh.setEnabled(false);
}
if(bsec == 1) {
secCh.setEnabled(true);
}else {
secCh.setEnabled(false);
}
if(broll == 1) {
rollTf.setEditable(true);
}else {
rollTf.setEditable(false);
}
if(bgender == 1) {
genderCh.setEnabled(true);
}else {
genderCh.setEnabled(false);
}
if(bmobile == 1) {
mobileTf.setEditable(true);
}else {
mobileTf.setEditable(false);
}
if(baddress == 1) {
permanentTf.setEditable(true);
}else {
permanentTf.setEditable(false);
}
//file
change_data = new File("D:\\Java Programs\\Java Eclipse\\EclipsePrograms\\IO files\\"+file_name+".txt");
String str;
try {
FileReader fr = new FileReader(change_data);
BufferedReader br = new BufferedReader(fr);
/*
*
* HERE: write from .txt to text fields
*
*
*/
while((str=br.readLine())!=null)
{
if(str.contains("★ Email address:-")){//email
String[] a=str.split("-",2);
emailTf.setText(a[1]);
}
if(str.contains("★ Select the Department:-")){//dept
String[] a=str.split("-",2);
deptCh.select(a[1]);
}
if(str.contains("★ Full Name:-")){//name
String[] a=str.split("-",2);
fullNameTf.setText(a[1]);
}
if(str.contains("★ Seeking Provisional Admission to:-")){ //adm yr
String[] a=str.split("-",2);
admYrCh.select(a[1]);
}
if(str.contains("★ Section:-")){ //section
String[] a=str.split("-",2);
secCh.select(a[1]);
}
if(str.contains("★ Roll No:-")){ //roll
String[] a=str.split("-",2);
rollTf.setText(a[1]);
}
if(str.contains("★ Gender:-")){ //gender
String[] a=str.split("-",2);
genderCh.select(a[1]);
}
if(str.contains("★ Student Mobile No:-")){ //mob no
String[] a=str.split("1",2);
mobileTf.setText(a[1]);
}
if(str.contains("★ Permanent Address:-")){
String[] a=str.split("-",2);
permanentTf.setText(a[1]);
}
}
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
System.out.print(e1);
}
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==submitB);
{
String check_email=registerDriverCodeForEmail();
String is_all_filled=registerDriverCodeForFields();
String is_mob_valid=registerDriverCodeForInvalidMobile();
// if(e.getSource()==submitB) {
email = emailTf.getText();
dept = deptCh.getSelectedItem();
fname = fullNameTf.getText() ;
adm = admYrCh.getSelectedItem();
sec = secCh.getSelectedItem();
roll = rollTf.getText();
gender = genderCh.getSelectedItem();
mobile = mobileTf.getText();
address = permanentTf.getText();
File student_data=new File("D:\\Java Programs\\Java Eclipse\\EclipsePrograms\\IO files\\"+filemain+".txt");
if(is_all_filled=="no")
{
emptypopup =new popupEmptyInformation1();
}
else if(check_email=="no")
{
emailpopup=new popupWrongEmail1();
}
else if(is_mob_valid=="no")
{
InvalidMobPop=new popupInvalidMobile1();
}else {
try
{
// student_data.createNewFile();
FileWriter filewriter=new FileWriter(student_data,false);
BufferedWriter writer=new BufferedWriter(filewriter);
writer.write(emailL.getText());
writer.write(email);
writer.write("\r");
writer.write(selectDeptL.getText());
writer.write(dept);
writer.write("\r");
writer.write(fullNameL.getText());
writer.write(fname);
writer.write("\r");
writer.write(admYrL.getText());
writer.write(adm);
writer.write("\r");
writer.write(secL.getText());
writer.write(sec);
writer.write("\r");
writer.write(rollL.getText());
writer.write(roll);
writer.write("\r");
writer.write(genderL.getText());
writer.write(gender);
writer.write("\r");
writer.write(mobileL.getText());
writer.write(mobileT.getText());
writer.write(mobile);
writer.write("\r");
writer.write(permanentL.getText());
writer.write(address);
writer.write("\r");
writer.flush();
writer.close();
filewriter.flush();
filewriter.close();
writer.write("\r");
writer.flush();
writer.close();
filewriter.flush();
filewriter.close();
}
catch(IOException ae)
{
}
sw=new succesful_written1();
dispose();
}
}
}
//here
String registerDriverCodeForFields()
{ String is_all_filled;
if(emailTf.getText().isEmpty()) //email
{
is_all_filled="no";
}
else if(deptCh.getSelectedItem().isEmpty()) //dept
{
is_all_filled="no";
}else if(fullNameTf.getText().isEmpty()) //fname
{
is_all_filled="no";
}else if(admYrCh.getSelectedItem().isEmpty()) //adm yr
{
is_all_filled="no";
}else if(secCh.getSelectedItem().isEmpty()) //section
{
is_all_filled="no";
}else if(rollTf.getText().isEmpty()) //roll
{
is_all_filled="no";
}else if(genderCh.getSelectedItem().isEmpty()) //gender
{
is_all_filled="no";
}else if(mobileTf.getText().isEmpty()) //mobile
{
is_all_filled="no";
}
else if(permanentTf.getText().isEmpty()) //address
{
is_all_filled="no";
}else
{
is_all_filled="else";
}
return is_all_filled;
}
String registerDriverCodeForEmail()
{
/*
* Email validation
*/
Pattern entered=Pattern.compile("^[\\w-\\.+]*[\\w-\\.]\\@([\\w]+\\.)+[\\w]+[\\w]$",Pattern.CASE_INSENSITIVE);
Matcher required=entered.matcher(emailTf.getText());
if(required.find())
{
is_email_valid="yes";
}
else
{
is_email_valid="no";
}
return is_email_valid;
}
/*
* Register driver code for invalid mobile
*/
String registerDriverCodeForInvalidMobile()
{
String is_mob_valid;
Pattern entered=Pattern.compile("^\\d{10}$",Pattern.CASE_INSENSITIVE);
Matcher required=entered.matcher(mobileTf.getText());
if(required.find())
{
is_mob_valid="yes";
}
else
{
is_mob_valid="no";
}
return is_mob_valid;
}
}//ctrl+shift+p
class Update_Radio extends Frame implements ActionListener,ItemListener { //TODO: here update ##2
Label task;
Checkbox email, dept, fname, adm, sec, roll, gender, mobile, address;
Button submit;
int bemail=0, bdept=0, bfname=0, badm=0, bsec=0, broll=0, bgender=0, bmobile=0, baddress=0;
String file_name;
Update_Radio(String s){
super("Update Form "+s+".txt");
file_name= s;
setSize(1000,1000);
setLayout(null);
setBackground(Color.black);
setForeground(Color.white);
setFont(new Font("serif",Font.BOLD,30));
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
dispose();
}
});
task=new Label(":: Select The Field/Fields You Want To Update ::",Label.CENTER);
task.setBounds(100, 70, 800, 40);
email = new Checkbox(" Email Address",false);
email.setBounds(100, 150, 300, 30);
dept=new Checkbox(" Department",false);
dept.setBounds(100, 200, 300, 30);
fname=new Checkbox(" Full Name",false);
fname.setBounds(100, 250, 300, 30);
adm=new Checkbox(" Provisional Admission Year",false);
adm.setBounds(100, 300, 400, 30);
sec=new Checkbox(" Section",false);
sec.setBounds(100, 350, 300, 30);
roll=new Checkbox(" Roll Number [Uneditable]",false);
roll.setBounds(100, 400, 400, 30);
roll.setEnabled(false);
gender=new Checkbox(" Gender",false);
gender.setBounds(100, 450,300, 30);
mobile=new Checkbox(" Mobile Number",false);
mobile.setBounds(100, 500, 300, 30);
address=new Checkbox(" Address",false);
address.setBounds(100, 550, 300, 30);
submit = new Button("PROCEED");
submit.setForeground(Color.black);
submit.setBounds(250, 650, 300, 50);
add(task);
add(email);
add(dept);
add(fname);
add(adm);
add(sec);
add(roll);
add(gender);
add(mobile);
add(address);
add(submit);
email.addItemListener(this);
dept.addItemListener(this);
fname.addItemListener(this);
adm.addItemListener(this);
sec.addItemListener(this);
roll.addItemListener(this);
gender.addItemListener(this);
mobile.addItemListener(this);
address.addItemListener(this);
submit.addActionListener(this);
}
@Override
public void itemStateChanged(ItemEvent e) {
if(e.getSource() == email) {
if(email.getState() == true) {
this.bemail = 1;
}else {
this.bemail = 0;
}
}
if(e.getSource() == dept) {
if(dept.getState() == true) {
this.bdept = 1;
}else {
this.bdept = 0;
}
}
if(e.getSource() == fname) {
if(fname.getState() == true) {
this.bfname = 1;
}else {
this.bfname = 0;
}
}
if(e.getSource() == adm) {
if(adm.getState() == true) {
this.badm = 1;
}
else {
this.badm = 0;
}
}
if(e.getSource() == sec) {
if(sec.getState() == true) {
this.bsec = 1;
}else {
this.bsec = 0;
}
}
if(e.getSource() == roll) {
if(roll.getState() == true) {
this.broll = 1;
}else {
this.broll = 0;
}
}
if(e.getSource() == gender) {
if(gender.getState() == true) {
this.bgender = 1;
}else {
this.bgender = 0;
}
}
if(e.getSource() == mobile) {
if(mobile.getState() == true) {
this.bmobile = 1;
}else {
this.bmobile = 0;
}
}
if(e.getSource() == address) {
if(address.getState() == true) {
this.baddress = 1;
}else {
this.baddress = 0;
}
}
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == submit) {
Update_Info u = null;
try {
u = new Update_Info(this.bemail,this.bdept,this.bfname,this.badm,this.bsec,this.broll,this.bgender,this.bmobile,this.baddress,"Write the change",file_name);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
u.setVisible(true);
}
}
}
class FormUpdateFrame extends Frame implements ActionListener { //TODO: here update ##1
Label filename;
TextField tfilename;
Button find;
Update_Radio updateRadio; //class obj
String name="";
popupEmptyInformation1 p1;
filenotfound1 fnf;
FormUpdateFrame(String string) {
super(string);
setBackground(Color.black);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{
dispose();
}
});
setFont(new Font("serif",Font.BOLD,30));
setLayout(null);
setSize(1000,1000);
filename=new Label(":: Enter Your Student ID ::");
filename.setForeground(Color.red);
tfilename=new TextField();
tfilename.setFont(new Font("serif",Font.BOLD,30));
find=new Button("UPDATE");
filename.setBounds(320,350,900,90);
tfilename.setBounds(350,450,300,40);
find.setBounds(350,500,300,50);
add(filename);
add(tfilename);
add(find);
find.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==find)//
{
name=tfilename.getText(); //
File student_data=new File("D:\\Java Programs\\Java Eclipse\\EclipsePrograms\\IO files\\"+name+".txt");//
if(student_data.exists() == true)//
{
updateRadio =new Update_Radio(name);
updateRadio.setVisible(true);
tfilename.setText("");
}
else if(name.isEmpty())
{
p1=new popupEmptyInformation1();
tfilename.setText("");
}
else if(student_data.exists() == false)
{
fnf=new filenotfound1();
tfilename.setText("");
}
}
}
}
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("serif",Font.BOLD,30));
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, 50);
//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, 50);
add(deleteL);
add(deleteFileTf);
add(deleteB);
add(deleteOutL);
add(deleteOutTf);
deleteB.addActionListener(this);
//close
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
deleteFileTf.setText("");
deleteOutTf.setText("");
dispose();
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == deleteB) {
str = deleteFileTf.getText();
File f = new File("D:\\Java Programs\\Java Eclipse\\EclipsePrograms\\IO files\\"+str+".txt");
if(deleteFileTf.getText().trim().isEmpty() == true) {
deleteOutTf.setText("Invalid ID");
deleteOutTf.setBackground(Color.black);
deleteOutTf.setForeground(Color.blue);
}
else if(f.exists() == true && deleteFileTf.getText().trim().isEmpty() == false) {
f.delete();
deleteOutTf.setBackground(Color.black);
deleteOutTf.setForeground(Color.GREEN);
deleteOutTf.setText("Form Deleted");
//pop-up: Class JOptionPane
JOptionPane.showMessageDialog(null,"Successfully Deleted!");
dispose();
deleteFileTf.setText("");
deleteOutTf.setText("");
}
else if(f.exists() == false && deleteFileTf.getText().trim().isEmpty() == false) {
deleteOutTf.setBackground(Color.black);
deleteOutTf.setForeground(Color.red);
deleteOutTf.setText("Form Does Not Exist");
}
}
}
}
class FormSearchFrame extends Frame implements ActionListener{ //form-search frame
//file-->
File fSearch;
//frame
TextField searchTf, searchOutTf;
Label searchL, searchOutL;
Button searchB, OpenB;
FormSearchFrame(String s){
super(s);
setLayout(null);
setSize(925,1050); //width - height
setFont(new Font("serif",Font.BOLD,30));
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, 50);
//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