forked from PrajaktaSathe/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwing_Simple_Registration_Form.java
More file actions
107 lines (103 loc) · 3.04 KB
/
Swing_Simple_Registration_Form.java
File metadata and controls
107 lines (103 loc) · 3.04 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
//GUI.java
import javax.util.Arrays;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.*;
public class GUI extends JFrame implements ActionListener{
JFrame jf;
JLabel jl1,jl2,jl3,jl4,jl5,jl6,jl7;
JTextField jtf1,jtf2,jtf3,jtf4;
JPasswordField jpf1,jpf2;
JButton jb1,jb2;
JComboBox jcb;
Container c;
GUI(){
jf=new JFrame("Registration Form");
c=jf.getContentPane();
jf.setLocation(100,100);
jf.setSize(350,350);
c.setBackground(Color.PINK);
jf.setLayout(null);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jl1=new JLabel("NAME");
jl2=new JLabel("GENDER");
jl3=new JLabel("FATHER NAME");
jl4=new JLabel("PASSWORD");
jl5=new JLabel("CONFIRM PASSWORD");
jl6=new JLabel("CITY");
jl7=new JLabel("EMAIL");
jl1.setBounds(10,50,200,20);
jl2.setBounds(10,70,200,20);
jl3.setBounds(10,90,200,20);
jl4.setBounds(10,110,200,20);
jl5.setBounds(10,130,200,20);
jl6.setBounds(10,150,200,20);
jl7.setBounds(10,170,200,20);
c.add(jl1);
c.add(jl2);
c.add(jl3);
c.add(jl4);
c.add(jl5);
c.add(jl6);
c.add(jl7);
jtf1=new JTextField();
jtf1.setBounds(150,50,150,20);
c.add(jtf1);
String[] str={"SELECT","Male","Female","Other"};
jcb=new JComboBox(str);
jcb.setBounds(150,70,150,20);
c.add(jcb);
jtf2=new JTextField();
jtf2.setBounds(150,90,150,20);
c.add(jtf2);
jpf1=new JPasswordField();
jpf1.setBounds(150,110,150,20);
c.add(jpf1);
jpf2=new JPasswordField();
jpf2.setBounds(150,130,150,20);
c.add(jpf2);
jtf3=new JTextField();
jtf3.setBounds(150,150,150,20);
c.add(jtf3);
jtf4=new JTextField();
jtf4.setBounds(150,170,150,20);
c.add(jtf4);
jb1=new JButton("Register");
jb1.setBounds(40,250,100,20);
jb1.addActionListener(this);
c.add(jb1);
jb2=new JButton("Reset");
jb2.setBounds(180,250,70,20);
jb2.addActionListener(this);
c.add(jb2);
jf.setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
if(ae.getSource()==jb1)
{ String p1 = jpf1.getText();
String p2 = jpf2.getText();
if(p1.equals(p2))
{
JOptionPane.showMessageDialog(jf,"Registered Succesfully");
}
else{
JOptionPane.showMessageDialog(jf,"Passwords didnt Matched","Alert",JOptionPane.WARNING_MESSAGE); }
}
else if(ae.getSource()==jb2){
jtf1.setText(null);
jtf2.setText(null);
jtf3.setText(null);
jtf4.setText(null);
jpf1.setText(null);
jpf2.setText(null);
jcb.setSelectedIndex(0);
}
}
}
//Main.java
public class Main {
public static void main(String[] args) {
new gui1();
}
}