-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteFrame.java
More file actions
66 lines (57 loc) · 1.2 KB
/
DeleteFrame.java
File metadata and controls
66 lines (57 loc) · 1.2 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class DeleteFrame extends JFrame{
Container c;
JLabel lblRno;
JTextField txtRno;
JButton btnSave,btnBack;
JPanel p1,p2;
DeleteFrame(){
c=getContentPane();
c.setLayout(new BoxLayout(c,BoxLayout.Y_AXIS));
p1=new JPanel();
lblRno=new JLabel("Rno:");
txtRno=new JTextField(4);
p1.add(lblRno);
p1.add(txtRno);
c.add(p1);
p2=new JPanel();
btnSave=new JButton("Save");
btnBack=new JButton("Back");
p2.add(btnSave);
p2.add(btnBack);
c.add(p2);
btnSave.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String rno2=txtRno.getText();
try
{
int rno=Integer.parseInt(rno2);
if(rno>0)
{
DbHandler db=new DbHandler();
db.deleteStudent(rno);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(new JDialog(),"Invalid Record");
}
txtRno.setText("");
txtRno.requestFocus();
}
});
btnBack.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
MainFrame a=new MainFrame();
dispose();
}
});
setTitle("Delete Student");
setSize(350,200);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}