-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteStudent.java
More file actions
137 lines (117 loc) · 4.47 KB
/
DeleteStudent.java
File metadata and controls
137 lines (117 loc) · 4.47 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.Image;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class DeleteStudent {
private static JFrame frame;
private JTextField textField;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
DeleteStudent window = new DeleteStudent();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public DeleteStudent() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 640, 460);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel lblDeleteLibrarian = new JLabel("Delete Student");
lblDeleteLibrarian.setForeground(Color.GRAY);
lblDeleteLibrarian.setFont(new Font("Tahoma", Font.PLAIN, 28));
JLabel lblEnterId = new JLabel("Enter ID :");
lblEnterId.setFont(new Font("Tahoma", Font.PLAIN, 18));
textField = new JTextField();
textField.setColumns(10);
JButton btnDelete = new JButton("Delete");
btnDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String sid=textField.getText();
if(sid==null||sid.trim().equals("")){
JOptionPane.showMessageDialog(DeleteStudent.frame,"Id can't be blank");
}else{
int id=Integer.parseInt(sid);
int i=StudentDao.delete(id);
if(i>0){
JOptionPane.showMessageDialog(DeleteStudent.frame,"Record deleted successfully!");
}else{
JOptionPane.showMessageDialog(DeleteStudent.frame,"Unable to delete given id!");
}
}
}
});
btnDelete.setFont(new Font("Tahoma", Font.PLAIN, 18));
JButton btnBack = new JButton("Back");
btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
LibrarianSuccess.main(new String[]{});
frame.dispose();
}
});
JLabel lblNewLabel = new JLabel("");
Image img4=new ImageIcon(this.getClass().getResource("/Delete.png")).getImage();
lblNewLabel.setIcon(new ImageIcon(img4));
GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
.addContainerGap(260, Short.MAX_VALUE)
.addComponent(btnDelete, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)
.addGap(154)
.addComponent(btnBack)
.addGap(26))
.addGroup(groupLayout.createSequentialGroup()
.addGap(214)
.addComponent(lblDeleteLibrarian)
.addContainerGap(213, Short.MAX_VALUE))
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblNewLabel, GroupLayout.PREFERRED_SIZE, 295, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createSequentialGroup()
.addGap(172)
.addComponent(lblEnterId)
.addPreferredGap(ComponentPlacement.RELATED, 66, Short.MAX_VALUE)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, 167, GroupLayout.PREFERRED_SIZE)))
.addGap(139))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblDeleteLibrarian)
.addGap(18)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblEnterId)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(lblNewLabel)
.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(btnBack)
.addComponent(btnDelete))
.addGap(48))
);
frame.getContentPane().setLayout(groupLayout);
}
}