-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyForm.java
More file actions
100 lines (95 loc) · 2.57 KB
/
MyForm.java
File metadata and controls
100 lines (95 loc) · 2.57 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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class MyForm extends JFrame implements ActionListener{
JButton ok;
JTextField name;
JTextField age;
JTextField mobno;
JTextArea schoff;
JTextArea con;
JTextArea email;
JTextArea fn;
JTextArea mn;
JLabel nameLabel;
JLabel ageLabel;
JLabel mobnoLabel;
JLabel schoffLabel;
JLabel conLabel;
JLabel emailLabel;
JLabel fnLabel;
JLabel mnLabel;
MyForm(){
super("Form");
setSize(300, 220);
setExtendedState(JFrame.MAXIMIZED_BOTH);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane=new JPanel();
nameLabel=new JLabel("Name: ");
ageLabel=new JLabel("Age: ");
mobnoLabel=new JLabel("Mobile No: ");
schoffLabel = new JLabel("Name of school or office:");
conLabel = new JLabel("Country:");
emailLabel = new JLabel("Email id:");
fnLabel = new JLabel("Fathers name:");
mnLabel = new JLabel("Mothers name:");
name=new JTextField(20);
age=new JTextField(5);
mobno=new JTextField(10);
schoff=new JTextArea(20, 20);
con=new JTextArea(20, 20);
email=new JTextArea(20, 20);
fn=new JTextArea(20, 20);
mn=new JTextArea(20, 20);
ok = new JButton("Submit");
ok.addActionListener(this);
pane.add("North West", nameLabel);
pane.add("North West", name);
pane.add("North", ageLabel);
pane.add("North", age);
pane.add("North East", mobnoLabel);
pane.add("North East", mobno);
pane.add("Center West", schoffLabel);
pane.add("Center West", schoff);
pane.add("Center", conLabel);
pane.add("Center", con);
pane.add("Center East", emailLabel);
pane.add("Center East", email);
pane.add("South West", mnLabel);
pane.add("South West", mn);
pane.add("South East", fnLabel);
pane.add("South East", fn);
pane.add("South", ok);
add (pane);
pack();
name.getText();
age.getText();
mobno.getText();
schoff.getText();
email.getText();
con.getText();
mn.getText();
fn.getText();
setVisible(true);
}
public void actionPerformed(ActionEvent evt){
Object source=evt.getSource();
if (source == ok){
JOptionPane.showMessageDialog(null, "Thank You", "Message", JOptionPane.PLAIN_MESSAGE);
}
repaint();
}
void setLookAndFeel() {
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
}
catch (Exception exc) {
System.err.println("Couldn't use the system "+"look and feel:"+exc);
}
}
public static void main(String[] args){
MyForm mf=new MyForm();
mf.setLookAndFeel();
}
}