package com.ouqisheng.view;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import com.ouqisheng.dao.TeacherDao;
import com.ouqisheng.model.Teacher;
import com.ouqisheng.util.StringUtil;
public class ManageTeacherFrm extends JInternalFrame {
private JTable teacherListTable;
private JTextField searchTeacherNameTextField;
private JTextField editTeacherNameTextField;
private JTextField editTeacherTitleTextField;
private JTextField editTeacherAgeTextField;
private JPasswordField editTeacherPasswordField;
private JRadioButton editTeacherSexManRadioButton;
private JRadioButton editTeacherSexFemalRadioButton;
private JButton deleteTeacherButton;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
ManageTeacherFrm frame = new ManageTeacherFrm();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public ManageTeacherFrm() {
setClosable(true);
setIconifiable(true);
setTitle("教师信息管理");
setBounds(100, 100, 805, 691);
JScrollPane scrollPane = new JScrollPane();
JLabel label = new JLabel("教师姓名:");
label.setIcon(new ImageIcon(ManageTeacherFrm.class.getResource("/images/\u8001\u5E08.png")));
label.setFont(new Font("微软雅黑", Font.PLAIN, 14));
searchTeacherNameTextField = new JTextField();
searchTeacherNameTextField.setColumns(10);
JButton searchTeacherButton = new JButton("查询");
searchTeacherButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
searchTeacher(e);
}
});
searchTeacherButton.setIcon(new ImageIcon(ManageTeacherFrm.class.getResource("/images/\u641C\u7D22.png")));
searchTeacherButton.setFont(new Font("微软雅黑", Font.PLAIN, 14));
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u6559\u5E08\u4FE1\u606F\u4FEE\u6539", TitledBorder.LEADING, TitledBorder.TOP, null, null));
GroupLayout groupLayout = new GroupLayout(getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING, false)
.addGroup(Alignment.LEADING, groupLayout.createSequentialGroup()
.addGap(178)
.addComponent(label)
.addGap(33)
.addComponent(searchTeacherNameTextField, GroupLayout.PREFERRED_SIZE, 179, GroupLayout.PREFERRED_SIZE)
.addGap(66)
.addComponent(searchTeacherButton))
.addGroup(Alignment.LEADING, groupLayout.createSequentialGroup()
.addGap(92)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(panel, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 610, Short.MAX_VALUE)
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 610, Short.MAX_VALUE))))
.addContainerGap(92, Short.MAX_VALUE))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(33)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(searchTeacherNameTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label)
.addComponent(searchTeacherButton))
.addGap(18)
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 323, GroupLayout.PREFERRED_SIZE)
.addGap(29)
.addComponent(panel, GroupLayout.PREFERRED_SIZE, 175, GroupLayout.PREFERRED_SIZE)
.addContainerGap(56, Short.MAX_VALUE))
);
JLabel label_1 = new JLabel("\u6559\u5E08\u59D3\u540D\uFF1A");
label_1.setIcon(new ImageIcon(ManageTeacherFrm.class.getResource("/images/\u8001\u5E08.png")));
label_1.setFont(new Font("微软雅黑", Font.PLAIN, 14));
editTeacherNameTextField = new JTextField();
editTeacherNameTextField.setColumns(10);
JLabel label_2 = new JLabel("\u6559\u5E08\u6027\u522B\uFF1A");
label_2.setIcon(new ImageIcon(ManageTeacherFrm.class.getResource("/images/\u6027\u522B.png")));
label_2.setFont(new Font("微软雅黑", Font.PLAIN, 14));
ButtonGroup buttonGroup = new ButtonGroup();
editTeacherSexManRadioButton = new JRadioButton("\u7537");
editTeacherSexManRadioButton.setSelected(true);
editTeacherSexFemalRadioButton = new JRadioButton("\u5973");
buttonGroup.add(editTeacherSexManRadioButton);
buttonGroup.add(editTeacherSexFemalRadioButton);
JLabel label_3 = new JLabel("\u6559\u5E08\u804C\u79F0\uFF1A");
label_3.setIcon(new ImageIcon(ManageTeacherFrm.class.getResource("/images/\u804C\u79F0\u8BC4\u5B9A.png")));
label_3.setFont(new Font("微软雅黑", Font.PLAIN, 14));
editTeacherTitleTextField = new JTextField();
editTeacherTitleTextField.setColumns(10);
JLabel label_4 = new JLabel("\u6559\u5E08\u5E74\u9F84\uFF1A");
label_4.setIcon(new ImageIcon(ManageTeacherFrm.class.getResource("/images/\u5E74\u9F84.png")));
label_4.setFont(new Font("微软雅黑", Font.PLAIN, 14));
editTeacherAgeTextField = new JTextField();
editTeacherAgeTextField.setColumns(10);
JLabel label_5 = new JLabel("\u767B\u5F55\u5BC6\u7801\uFF1A");
label_5.setIcon(new ImageIcon(ManageTeacherFrm.class.getResource("/images/\u5BC6\u7801.png")));
label_5.setFont(new Font("微软雅黑", Font.PLAIN, 14));
editTeacherPasswordField = new JPasswordField();
JButton editTeacherSubmitButton = new JButton("\u786E\u8BA4\u4FEE\u6539");
editTeacherSubmitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
editTeacherAct(ae);
}
});
editTeacherSubmitButton.setIcon(new ImageIcon(ManageTeacherFrm.class.getResource("/images/\u786E\u8BA4.png")));
editTeacherSubmitButton.setFont(new Font("微软雅黑", Font.PLAIN, 14));
deleteTeacherButton = new JButton("\u5220\u9664\u4FE1\u606F");
deleteTeacherButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
deleteTeacher(ae);
}
});
deleteTeacherButton.setIcon(new ImageIcon(ManageTeacherFrm.class.getResource("/images/\u5220\u9664.png")));
deleteTeacherButton.setFont(new Font("微软雅黑", Font.PLAIN, 14));
GroupLayout gl_panel = new GroupLayout(panel);
gl_panel.setHorizontalGroup(
gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addGap(24)
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addComponent(label_1)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(editTeacherNameTextField, GroupLayout.PREFERRED_SIZE, 122, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel.createSequentialGroup()
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addComponent(label_3)
.addComponent(label_5))
.ad