-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMyForm.java
85 lines (78 loc) · 2.2 KB
/
MyForm.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
import javax.swing.*;
class MyForm {
//main method
public static void main(String[] args){
//creating frame
JFrame obj=new JFrame("Form using swing");
//creating labels
JLabel form=new JLabel("Sign Up Form");
JLabel name=new JLabel("Name:");
JLabel age=new JLabel("Age:");
JLabel gender=new JLabel("Gender:");
JLabel email=new JLabel("Email:");
JLabel psw=new JLabel("Password:");
JLabel cb=new JLabel("Select programming language you want to learn:-");
//creating textfields
JTextField name_t=new JTextField(20);
JTextField age_t=new JTextField(20);
JTextField email_t=new JTextField(20);
//creating passwordfield
JPasswordField psw_t=new JPasswordField(20);
//creating radio buttons
JRadioButton rb_m=new JRadioButton("Male");
JRadioButton rb_f=new JRadioButton("Female");
JRadioButton rb_o=new JRadioButton("Other");
//creating checkboxes
JCheckBox cb_c=new JCheckBox("C");
JCheckBox cb_cpp=new JCheckBox("C++");
JCheckBox cb_java=new JCheckBox("Java");
JCheckBox cb_py=new JCheckBox("Python");
//creating signup button
JButton login=new JButton("Sign up");
//setting bounds of each component
form.setBounds(110,10,100,15);
name.setBounds(15,35,70,25);
name_t.setBounds(85,35,140,25);
age.setBounds(15,65,70,25);
age_t.setBounds(85,65,140,25);
gender.setBounds(15,95,70,25);
rb_m.setBounds(60,95,65,25);
rb_f.setBounds(125,95,70,25);
rb_o.setBounds(205,95,65,25);
email.setBounds(15,125,70,25);
email_t.setBounds(85,125,140,25);
psw.setBounds(15,155,70,25);
psw_t.setBounds(85,155,140,25);
cb.setBounds(15,185,300,25);
cb_c.setBounds(15,205,65,25);
cb_cpp.setBounds(15,225,65,25);
cb_java.setBounds(15,245,65,25);
cb_py.setBounds(15,265,70,25);
login.setBounds(100,295,100,25);
//adding components into frame
obj.add(form);
obj.add(name);
obj.add(name_t);
obj.add(age);
obj.add(age_t);
obj.add(gender);
obj.add(rb_m);
obj.add(rb_f);
obj.add(rb_o);
obj.add(email);
obj.add(email_t);
obj.add(psw);
obj.add(psw_t);
obj.add(cb);
obj.add(cb_c);
obj.add(cb_cpp);
obj.add(cb_java);
obj.add(cb_py);
obj.add(login);
//customizing frame
obj.setSize(350,380);
obj.setLayout(null);
obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//closing the JFrame
obj.setVisible(true);
}
}