-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddSt.java
112 lines (90 loc) · 2.88 KB
/
AddSt.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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.EmptyBorder;
public class AddSt implements ActionListener{
JFrame jf;
JPanel jp;
JLabel labname,labid,labrno,labcrs,labyr;
JButton save,exit;
JTextField txtname,txtid,txtrno,txtcrs,txtyr;
AddSt()
{
labid=new JLabel("Student ID", null, 0);
labrno=new JLabel("Student Roll Number", null, 0);
labcrs=new JLabel("Student Course", null, 0);
labyr=new JLabel("Course Year", null, 0);
labname=new JLabel("Student Name", null, 0);
txtname=new JTextField(20);
txtid=new JTextField(10);
txtrno=new JTextField(10);
txtcrs=new JTextField(20);
txtyr=new JTextField(2);
save=new JButton("SAVE", null);
exit=new JButton("EXIT", null);
save.addActionListener(this);
exit.addActionListener(this);
jp=new JPanel(new GridBagLayout(), false);
jp.setPreferredSize(new Dimension(400, 300));
jf=new JFrame("REGISTER STUDENT", null);
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 5, 5, 5);
gbc.ipadx = 50;
gbc.ipady = 30;
gbc.gridx = 0;
gbc.gridy = 0;
jp.add(labid, gbc);
gbc.gridx = 1;
jp.add(txtid, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
jp.add(labname, gbc);
gbc.gridx = 1;
jp.add(txtname, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
jp.add(labrno, gbc);
gbc.gridx = 1;
jp.add(txtrno, gbc);
gbc.gridx = 0;
gbc.gridy = 3;
jp.add(labcrs, gbc);
gbc.gridx = 1;
jp.add(txtcrs, gbc);
gbc.gridx = 0;
gbc.gridy = 4;
jp.add(labyr, gbc);
gbc.gridx = 1;
jp.add(txtyr, gbc);
gbc.gridx = 0;
gbc.gridy = 5;
jp.add(exit, gbc);
gbc.gridx = 1;
jp.add(save, gbc);
jp.setBorder(new EmptyBorder(30, 100, 30, 100));
jf.add(jp);
jf.setSize(900,500);
jf.setVisible(true);;
jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
if(s=="SAVE")
{
Main.obj.addStudent(txtname.getText(), Long.parseLong(txtrno.getText()), Long.parseLong(txtid.getText()), txtcrs.getText(), Integer.parseInt(txtyr.getText()));
save.setText("Student Added!!!");
}
else
jf.dispose();
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run()
{
new AddSt();
}
});
}
}