-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateStudentPanel.java
More file actions
76 lines (65 loc) · 1.81 KB
/
CreateStudentPanel.java
File metadata and controls
76 lines (65 loc) · 1.81 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
package com.cruds.swingproj;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.cruds.exception.SMSException;
public class CreateStudentPanel extends JPanel
{
JTextField txtUSN;
JLabel lblUSN;
JTextField txtsname;
JLabel lblsname;
JButton btncreate;
JButton btnhome;
public CreateStudentPanel()
{
lblUSN = new JLabel("Student USN");
txtUSN = new JTextField(10);
lblsname = new JLabel("Student Name");
txtsname = new JTextField(10);
btncreate = new JButton("Create");
btncreate.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{
String strUSN = txtUSN.getText();
String strname = txtsname.getText();
try
{
Student s = new Student(strUSN, strname);
BookDAO dao = new BookDAO();
if(dao.create(s))
{
txtUSN.setText("");
txtsname.setText("");
JOptionPane.showMessageDialog(getParent(), "Student Created Successfully", "Success", JOptionPane.INFORMATION_MESSAGE);
}
}
catch(SMSException smse)
{
getToolkit().beep();
JOptionPane.showMessageDialog(getParent(), smse.getInfo(), "Error", JOptionPane.ERROR_MESSAGE);
}
}
});
btnhome = new JButton("Home");
btnhome.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
CardLayout card = (CardLayout) getParent().getLayout();
card.show(getParent(),"HOMEPANEL");
}
});
add(lblUSN);
add(txtUSN);
add(lblsname);
add(txtsname);
add(btncreate);
add(btnhome);
}
}