-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeleteFrame.java
81 lines (63 loc) · 1.37 KB
/
DeleteFrame.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DeleteFrame extends JFrame
{
JPanel jp1,jp2;
JButton delete,back;
JTextField t1;
JLabel l1;
public DeleteFrame()
{
super("Delete Employee");
setSize(500,150);
setResizable(false);
jp1=new JPanel();
jp1.setLayout(new FlowLayout(FlowLayout.CENTER,10,25));
delete=new JButton("Delete");
back=new JButton("Back");
l1=new JLabel("id:");
t1=new JTextField(5);
jp1.add(l1);
jp1.add(t1);
add(jp1);
jp2=new JPanel();
jp2.setLayout(new FlowLayout(FlowLayout.CENTER,10,25));
jp2.add(delete);
jp2.add(back);
add(jp2,BorderLayout.SOUTH);
setLocationRelativeTo(null);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
HomeFrame h=new HomeFrame();
dispose();
}
});
back.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
HomeFrame h=new HomeFrame();
dispose();
}
});
delete.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
String id=t1.getText();
if(id.length()==0)
{
JOptionPane.showMessageDialog(new JDialog(),"Id cannot be Empty");
return;
}
DatabaseHandler q=new DatabaseHandler();
q.delete(Integer.parseInt(id));
t1.setText("");
}
});
}
}