📄 studentadddialog.java
字号:
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
package com.hb.stumanagesys.basicinfomaintain;
// import FileFilter;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import com.hb.jdbcconnct.JdbcConnct;
import com.hb.stumanagesys.CalendarJDialog;
/**
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
* Builder, which is free for non-commercial use. If Jigloo is being used
* commercially (ie, by a corporation, company or business for any purpose
* whatever) then you should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details. Use of Jigloo implies
* acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
* PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
* ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class StudentAddDialog extends javax.swing.JDialog {
public JPanel stumagPanel;
public JLabel stuNameLabel;
public JTextField stuNameTextField;
public JLabel jLabel1;
public JTextField contactWayTextField;
public JButton querypicButton;
public JTextField pathTextField;
public JSeparator student2Separator;
public JButton submitButton;
public JButton exsitButton;
public JButton addButton;
public JLabel photoLabel;
public JScrollPane remarkScrollPane;
public JTextArea remarkTextArea;
public JLabel remarkLabel;
public JScrollPane infoScrollPane;
public JTextArea infoTextArea;
public JLabel infoLabel;
public JComboBox statusComboBox;
public JLabel statusLabel;
public JTextField enterTimeTextField;
public JLabel enterTimeLabel;
public JTextField classIdTextField;
public JLabel classIdLabel;
public JTextField nativeTextField;
public JLabel nativeLabel;
public JLabel contactWayLabel;
public JTextField birthDayTextField;
public JLabel birthDayLabel;
public JComboBox poliStatusComboBox;
public JLabel poliStatusLabel;
public JTextField ageTextField;
public JLabel ageLabel;
public ButtonGroup genderbuttonGroup;
public JRadioButton famelRadioButton;
public JRadioButton manRadioButton;
public JLabel genderLabel;
public JTextField studentIdTextField;
public JLabel studentIdLabel;
// 定义学号的正则表达式
public final static String REG_DIGTEAID = "[1-9]\\d{0,6}";
// 定义年龄的正则表达式
public final static String REG_DIGAGE = "\\d{1,2}";
// 定义并初始化控制变量
boolean stuNamecontrol = false;
boolean stuIdcontrol = false;
boolean agecontrol = false;
JdbcConnct jdbc ;
/**
* Auto-generated main method to display this JDialog
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
StudentAddDialog inst = new StudentAddDialog(frame);
inst.setVisible(true);
inst.setLocationRelativeTo(null);
}
public StudentAddDialog(JFrame frame) {
super(frame);
initGUI();
}
public void initGUI() {
try {
{
getContentPane().setBackground(new java.awt.Color(0, 128, 255));
this.setTitle("\u6dfb\u52a0\u5b66\u751f");
{
{
genderbuttonGroup = new ButtonGroup();
}
stumagPanel = new JPanel();
getContentPane().add(stumagPanel, BorderLayout.CENTER);
stumagPanel
.setBackground(new java.awt.Color(182, 179, 234));
stumagPanel.setLayout(null);
stumagPanel.setSize(525, 574);
stumagPanel.setPreferredSize(new java.awt.Dimension(658,
546));
{
stuNameLabel = new JLabel();
stumagPanel.add(stuNameLabel);
stuNameLabel.setText("\u59d3\u540d");
stuNameLabel.setBounds(196, 21, 49, 21);
}
{
stuNameTextField = new JTextField();
stumagPanel.add(stuNameTextField);
stuNameTextField.setBounds(245, 21, 98, 28);
}
{
studentIdLabel = new JLabel();
stumagPanel.add(studentIdLabel);
studentIdLabel.setText("\u5b66\u53f7");
studentIdLabel.setBounds(21, 21, 42, 28);
}
{
studentIdTextField = new JTextField();
stumagPanel.add(studentIdTextField);
studentIdTextField.setBounds(77, 21, 98, 28);
}
{
genderLabel = new JLabel();
stumagPanel.add(genderLabel);
genderLabel.setText("\u6027\u522b");
genderLabel.setBounds(21, 77, 63, 28);
}
{
famelRadioButton = new JRadioButton();
stumagPanel.add(famelRadioButton);
famelRadioButton.setText("\u5973");
famelRadioButton.setBounds(126, 77, 42, 28);
genderbuttonGroup.add(famelRadioButton);
}
{
ageLabel = new JLabel();
stumagPanel.add(ageLabel);
ageLabel.setText("\u5e74\u9f84");
ageLabel.setBounds(196, 77, 42, 28);
}
{
ageTextField = new JTextField();
stumagPanel.add(ageTextField);
ageTextField.setBounds(245, 77, 98, 28);
}
{
poliStatusLabel = new JLabel();
stumagPanel.add(poliStatusLabel);
poliStatusLabel.setText("\u653f\u6cbb\u9762\u8c8c");
poliStatusLabel.setBounds(21, 126, 56, 28);
}
{
ComboBoxModel poliStatusComboBoxModel = new DefaultComboBoxModel(
new String[] { "共青团员", "党员", "群众", "其它党派" });
poliStatusComboBox = new JComboBox();
stumagPanel.add(poliStatusComboBox);
poliStatusComboBox.setModel(poliStatusComboBoxModel);
poliStatusComboBox.setBounds(84, 126, 84, 28);
}
{
birthDayLabel = new JLabel();
stumagPanel.add(birthDayLabel);
birthDayLabel.setText("\u51fa\u751f\u65e5\u671f");
birthDayLabel.setBounds(21, 196, 63, 28);
}
{
birthDayTextField = new JTextField();
stumagPanel.add(birthDayTextField);
birthDayTextField.setBounds(84, 196, 98, 28);
birthDayTextField.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
birthDayTextFieldMouseClicked(evt);
}
});
}
{
contactWayLabel = new JLabel();
stumagPanel.add(contactWayLabel);
contactWayLabel.setText("\u8054\u7cfb\u65b9\u5f0f");
contactWayLabel.setBounds(21, 273, 56, 28);
}
{
nativeLabel = new JLabel();
stumagPanel.add(nativeLabel);
nativeLabel.setText("\u7c4d\u8d2f");
nativeLabel.setBounds(196, 126, 49, 28);
}
{
nativeTextField = new JTextField();
stumagPanel.add(nativeTextField);
nativeTextField.setBounds(245, 126, 98, 28);
}
{
classIdLabel = new JLabel();
stumagPanel.add(classIdLabel);
classIdLabel.setText("\u73ed\u7ea7\u540d");
classIdLabel.setBounds(357, 21, 56, 28);
}
{
classIdTextField = new JTextField();
stumagPanel.add(classIdTextField);
classIdTextField.setBounds(427, 21, 91, 28);
}
{
enterTimeLabel = new JLabel();
stumagPanel.add(enterTimeLabel);
enterTimeLabel.setText("\u5165\u5b66\u65f6\u95f4");
enterTimeLabel.setBounds(364, 77, 56, 28);
}
{
enterTimeTextField = new JTextField();
stumagPanel.add(enterTimeTextField);
enterTimeTextField.setBounds(427, 77, 91, 28);
enterTimeTextField.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
enterTimeTextFieldMouseClicked(evt);
}
});
}
{
statusLabel = new JLabel();
stumagPanel.add(statusLabel);
statusLabel.setText("\u72b6\u6001");
statusLabel.setBounds(364, 126, 49, 28);
}
{
ComboBoxModel statusComboBoxModel = new DefaultComboBoxModel(
new String[] { "在读", "休学", "退学", "毕业", "其它" });
statusComboBox = new JComboBox();
stumagPanel.add(statusComboBox);
statusComboBox.setModel(statusComboBoxModel);
statusComboBox.setBounds(427, 126, 63, 28);
}
{
infoLabel = new JLabel();
stumagPanel.add(infoLabel);
infoLabel.setText("\u4e2a\u4eba\u7b80\u4ecb");
infoLabel.setBounds(21, 322, 63, 28);
}
{
infoScrollPane = new JScrollPane();
stumagPanel.add(infoScrollPane);
infoScrollPane.setBounds(77, 329, 147, 91);
{
infoTextArea = new JTextArea();
infoScrollPane.setViewportView(infoTextArea);
infoTextArea.setBounds(189, 252, 77, 91);
infoTextArea.setLineWrap(true);
infoTextArea
.setPreferredSize(new java.awt.Dimension(
129, 102));
}
}
{
remarkLabel = new JLabel();
stumagPanel.add(remarkLabel);
remarkLabel.setText("\u5907\u6ce8");
remarkLabel.setBounds(259, 322, 63, 28);
}
{
remarkScrollPane = new JScrollPane();
stumagPanel.add(remarkScrollPane);
remarkScrollPane.setBounds(301, 343, 112, 42);
{
remarkTextArea = new JTextArea();
remarkScrollPane.setViewportView(remarkTextArea);
remarkTextArea.setBounds(371, 294, 105, 84);
remarkTextArea.setLineWrap(true);
remarkTextArea
.setPreferredSize(new java.awt.Dimension(
109, 61));
}
}
{
photoLabel = new JLabel();
stumagPanel.add(photoLabel);
photoLabel.setText(" \u7167\u7247");
photoLabel.setBounds(455, 224, 84, 112);
photoLabel.setBackground(new java.awt.Color(192, 192,
192));
photoLabel.setOpaque(true);
}
{
addButton = new JButton();
stumagPanel.add(addButton);
addButton.setText("\u6dfb\u52a0");
addButton.setBounds(112, 462, 70, 28);
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
addButtonActionPerformed(evt);
} catch (SQLException e) {
e.printStackTrace();
}
}
});
}
{
exsitButton = new JButton();
stumagPanel.add(exsitButton);
exsitButton.setText("\u9000\u51fa");
exsitButton.setBounds(322, 462, 70, 28);
exsitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
exsitButtonActionPerformed(evt);
}
});
}
{
submitButton = new JButton();
stumagPanel.add(submitButton);
submitButton.setText("\u4fee\u6539");
submitButton.setBounds(217, 462, 70, 28);
submitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
submitButtonActionPerformed(evt);
}
});
}
{
student2Separator = new JSeparator();
stumagPanel.add(student2Separator);
student2Separator.setBounds(56, 441, 476, 154);
}
{
pathTextField = new JTextField();
stumagPanel.add(pathTextField);
pathTextField.setBounds(434, 189, 91, 28);
}
{
querypicButton = new JButton();
stumagPanel.add(querypicButton);
querypicButton.setText("\u67e5\u627e");
querypicButton.setBounds(364, 189, 63, 28);
querypicButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
querypicButtonActionPerformed(evt);
}
});
}
{
manRadioButton = new JRadioButton();
stumagPanel.add(manRadioButton);
manRadioButton.setText("\u7537");
manRadioButton.setBounds(84, 77, 42, 28);
genderbuttonGroup.add(manRadioButton);
manRadioButton.setSelected(true);
}
{
contactWayTextField = new JTextField();
stumagPanel.add(contactWayTextField);
contactWayTextField.setBounds(77, 273, 119, 28);
}
{
jLabel1 = new JLabel();
stumagPanel.add(jLabel1);
jLabel1.setText("\u653f\u6cbb\u9762\u8c8c");
jLabel1.setBounds(21, 126, 56, 28);
}
}
}
this.setSize(600, 575);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 取得专业名称
*
* @return
*/
public String[] getMajorName() {
try {
// Class.forName("oracle.jdbc.driver.OracleDriver");
// String url = "jdbc:oracle:thin:@192.168.111.79:1521:orcl";
// String user = "zlb";
// String pwd = "hb2080";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
Vector majorVector = new Vector();
//获取连接
conn = conn = JdbcConnct.fetchConnection();
//查询sql语句
String sql = "select majorname from major ";
//创建statement对象
stmt = conn.createStatement();
//获得结果集
rs = stmt.executeQuery(sql);
//对结果集进行处理操作
while (rs.next()) {
majorVector.addElement((String) rs.getString(1));
}//把专业名存放到数组中
String[] studentName = new String[majorVector.size()];
for (int i = 0; i < majorVector.size(); i++) {
studentName[i] = (String) majorVector.elementAt(i);
// System.out.println(studentName[i]);
}
//关闭结果集
rs.close();
//关闭statement对象
stmt.close();
//关闭连接
conn.close();
//返回专业
return studentName;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -