-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddFrame.java
91 lines (50 loc) · 1.22 KB
/
AddFrame.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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class AddFrame extends JFrame
{
Container c;
JButton btnSave,btnBack;
JLabel lblrno,lblname;
JTextField txtrno,txtname;
AddFrame()
{
c= getContentPane();
c.setLayout(new FlowLayout());
lblrno = new JLabel("Enter RNO");
lblname = new JLabel("Enter name");
txtrno = new JTextField(10);
txtname = new JTextField(10);
btnSave = new JButton("Save");
btnBack = new JButton("Back");
c.add(lblrno);
c.add(txtrno);
c.add(lblname);
c.add(txtname);
c.add(btnSave);
c.add(btnBack);
setTitle("Add Frame");
setSize(255,180);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
btnSave.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
String rno = txtrno.getText();
String name = txtname.getText();
DbHandler db = new DbHandler();
db.addStudent(rno,name);
txtrno.setText("");
txtname.setText("");
txtrno.requestFocus();
}
});
btnBack.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
MainFrame m = new MainFrame();
dispose();
}
});
}
} // end of class