📄 stumatchclassdialog.java
字号:
package com.hb.stumanagesys.basicinfomaintain;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import com.hb.jdbcconnct.JdbcConnct;
import com.hb.stumanagesys.CalendarJDialog;
import com.hb.stumanagesys.basicinfomaintain.ClassMagDialog.Class;
/**
* 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 StuMatchClassDialog extends javax.swing.JDialog {
private JPanel StuMatchClassPanel;
private JLabel StuInfoLabel;
private JComboBox stuQueryConditionComboBox;
private JButton stuQueryButton;
private JLabel queryByDateLabel;
private JTextField dateInputTextField;
private JTextField userInputTextField;
private JList sqlViewList1;
private JScrollPane sqlViewScrollPane;
private JButton clearButton;
private JButton addButton;
private JComboBox compareSymbolComboBox;
private JPanel dataPanel;
private JPanel studentQueryPanel1;
private JTabbedPane stuMatchClassTabbedPane1;
private JButton DeleteButton;
private JRadioButton andjRadioButton;
private JButton ExitButton;
private JButton SelectButton;
protected JTable SelectStuTable;
private JTable StuInfoTable;
private JScrollPane SelectStuScrollPane;
private JScrollPane StuInfoScrollPane;
private JLabel SelectStuInfoLabel;
private ButtonGroup QuerybuttonGroup;
private JRadioButton orRadioButton;
private JRadioButton nullRadioButton;
private JLabel ClassNameLabel;
private JLabel ClassIdLabel;
//定义学生信息表模型 DefaultTableModel StuInfoTableModel;
//定义班级学生表的模型 DefaultTableModel SelectStuTableModel;
//定义String二维数组,初始化学生信息表studentInfoTable
String[][] row;
//学生信息表标题及查询字段 String[] columnStudent ={ "学号", "姓名", "性别", "年龄","生日","班级编号","入学日期" };
String[] columnStudentQuery ={ "学号", "姓名", "性别", "年龄","生日","入学日期" };
//班级信息 班级编号、班级名、班主任编号、学生人数、届别、专业 //判断条件 private String[] comCompareList = { ">", "<", "=" };
//定义Vector变量vecSQL,存储SQL子句 Vector vecSQL = new Vector(20);
//vecListView,用于在List控件中显示SQL子句 Vector vecListView = new Vector(20);
private JLabel jLabel2;
private JLabel jLabel1;
JLabel selectedStuNumLabel;
JLabel unselectedStuNumLabel1;
JLabel stuNumViewLabel;
private JLabel stuNumLabel;
JLabel classNameViewLabel;
JLabel classIdViewLabel;
//定义用户查询条件数量,初始化为1
int ncount = 1;
//定义未选学生人数 int nunselectedStuNum = 0;
//定义已选学生人数 int nselectedStuNum = 0;
//正则表达式,校验用户输入的学号、年龄、日期 String REG_DITAGE = "[1-9]\\d{0,2}";
String REG_DITSTUNUM = "[1-9]\\d{0,9}";
//正则表达式,匹配日期 String REG_DATE = "[1-9]\\d{3}\\-[0-1]\\d{0,1}\\-[0-3]\\d{0,1}" +
"|[1-9]\\d{3}\\-\\d{0,1}\\-\\d{0,1}";
/**
* Auto-generated main method to display this JDialog
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
StuMatchClassDialog inst = new StuMatchClassDialog(frame);
inst.setVisible(true);
inst.setLocationRelativeTo(null);
}
public StuMatchClassDialog(JFrame frame) {
super(frame);
initGUI();
}
private void initGUI() {
try {
{
getContentPane().setLayout(null);
this.setTitle("\u4e3a\u73ed\u7ea7\u5206\u914d\u5b66\u751f");
{
{
QuerybuttonGroup = new ButtonGroup();
}
StuMatchClassPanel = new JPanel();
getContentPane().add(StuMatchClassPanel);
StuMatchClassPanel.setBounds(0, 0, 900, 475);
StuMatchClassPanel.setBackground(new java.awt.Color(185,185,255));
StuMatchClassPanel.setLayout(null);
{
ClassIdLabel = new JLabel();
StuMatchClassPanel.add(ClassIdLabel);
ClassIdLabel.setText("\u73ed\u7ea7\u7f16\u53f7");
ClassIdLabel.setBounds(518, 7, 56, 28);
}
{
classIdViewLabel = new JLabel();
StuMatchClassPanel.add(classIdViewLabel);
classIdViewLabel.setText("0");
classIdViewLabel.setBounds(581, 7, 56, 28);
classIdViewLabel.setForeground(new java.awt.Color(0,0,255));
}
{
classNameViewLabel = new JLabel();
StuMatchClassPanel.add(classNameViewLabel);
classNameViewLabel.setText("\u73ed\u7ea7\u540d");
classNameViewLabel.setBounds(700, 7, 161, 28);
classNameViewLabel.setForeground(new java.awt.Color(0,0,255));
}
{
ClassNameLabel = new JLabel();
StuMatchClassPanel.add(ClassNameLabel);
ClassNameLabel.setText("\u73ed\u540d");
ClassNameLabel.setBounds(651, 7, 49, 28);
ClassNameLabel.setForeground(new java.awt.Color(0,0,0));
}
{
stuNumLabel = new JLabel();
StuMatchClassPanel.add(stuNumLabel);
stuNumLabel.setText("\u73ed\u7ea7\u4eba\u6570");
stuNumLabel.setBounds(518, 42, 56, 28);
}
{
stuNumViewLabel = new JLabel();
StuMatchClassPanel.add(stuNumViewLabel);
stuNumViewLabel.setText("\u4eba\u6570");
stuNumViewLabel.setBounds(581, 42, 49, 28);
stuNumViewLabel.setForeground(new java.awt.Color(0,0,255));
}
{
SelectStuInfoLabel = new JLabel();
StuMatchClassPanel.add(SelectStuInfoLabel);
SelectStuInfoLabel.setText("\u5df2\u9009\u5b66\u751f\uff1a");
SelectStuInfoLabel.setBounds(630, 56, 70, 28);
SelectStuInfoLabel.setForeground(new java.awt.Color(0,0,255));
}
{
SelectStuScrollPane = new JScrollPane();
StuMatchClassPanel.add(SelectStuScrollPane);
SelectStuScrollPane.setBounds(518, 84, 343, 336);
{
SelectStuTableModel = new DefaultTableModel(
row,
columnStudent);
SelectStuTable = new JTable();
SelectStuScrollPane.setViewportView(SelectStuTable);
SelectStuTable.setModel(SelectStuTableModel);
//设置学生信息表每个单元格的高度 SelectStuTable.setRowHeight(24);
SelectStuTable.setBounds(231, 385, 119, 112);
SelectStuTable.setPreferredSize(new java.awt.Dimension(322, 2786));
}
}
{
ExitButton = new JButton();
StuMatchClassPanel.add(ExitButton);
ExitButton.setText("\u9000\u51fa");
ExitButton.setBounds(798, 441, 70, 21);
ExitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ExitButtonActionPerformed(evt);
}
});
}
{
stuMatchClassTabbedPane1 = new JTabbedPane();
StuMatchClassPanel.add(stuMatchClassTabbedPane1);
stuMatchClassTabbedPane1.setBounds(21, 21, 476, 427);
{
studentQueryPanel1 = new JPanel();
stuMatchClassTabbedPane1.addTab("学生查询", null, studentQueryPanel1, null);
studentQueryPanel1.setLayout(null);
studentQueryPanel1.setBounds(21, 42, 469, 399);
{
ComboBoxModel StuQueryComboBoxModel = new DefaultComboBoxModel(
columnStudentQuery);
stuQueryConditionComboBox = new JComboBox();
studentQueryPanel1
.add(stuQueryConditionComboBox);
stuQueryConditionComboBox
.setModel(StuQueryComboBoxModel);
stuQueryConditionComboBox.setBounds(
14,
14,
70,
28);
stuQueryConditionComboBox
.addActionListener(new ActionListener() {
public void actionPerformed(
ActionEvent evt) {
stuQueryConditionComboBoxActionPerformed(evt);
}
});
}
{
ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(
comCompareList);
compareSymbolComboBox = new JComboBox();
studentQueryPanel1.add(compareSymbolComboBox);
compareSymbolComboBox.setModel(jComboBox1Model);
compareSymbolComboBox
.setBounds(112, 14, 70, 28);
}
{
nullRadioButton = new JRadioButton();
studentQueryPanel1.add(nullRadioButton);
nullRadioButton.setText("\u65e0");
nullRadioButton.setBounds(14, 98, 70, 21);
QuerybuttonGroup.add(nullRadioButton);
nullRadioButton.setSelected(true);
}
{
andjRadioButton = new JRadioButton();
studentQueryPanel1.add(andjRadioButton);
andjRadioButton.setText("\u6216\u8005");
andjRadioButton.setBounds(91, 98, 70, 21);
QuerybuttonGroup.add(andjRadioButton);
}
{
orRadioButton = new JRadioButton();
studentQueryPanel1.add(orRadioButton);
orRadioButton.setText("\u5e76\u4e14");
orRadioButton.setBounds(168, 98, 70, 21);
QuerybuttonGroup.add(orRadioButton);
}
{
stuQueryButton = new JButton();
studentQueryPanel1.add(stuQueryButton);
stuQueryButton.setText("\u67e5\u8be2");
stuQueryButton.setBounds(21, 343, 70, 21);
stuQueryButton
.addActionListener(new ActionListener() {
public void actionPerformed(
ActionEvent evt) {
stuQueryButtonActionPerformed(evt);
}
});
}
{
addButton = new JButton();
studentQueryPanel1.add(addButton);
addButton.setText("\u6dfb\u52a0");
addButton.setBounds(203, 343, 70, 21);
addButton
.addActionListener(new ActionListener() {
public void actionPerformed(
ActionEvent evt) {
addButtonActionPerformed(evt);
}
});
}
{
clearButton = new JButton();
studentQueryPanel1.add(clearButton);
clearButton.setText("\u6e05\u7a7a");
clearButton.setBounds(112, 343, 70, 21);
clearButton
.addActionListener(new ActionListener() {
public void actionPerformed(
ActionEvent evt) {
clearButtonActionPerformed(evt);
}
});
}
{
sqlViewScrollPane = new JScrollPane();
studentQueryPanel1.add(sqlViewScrollPane);
sqlViewScrollPane.setBounds(21, 133, 217, 189);
{
ListModel sqlViewList1Model = new DefaultComboBoxModel(
new String[] { "", "" });
sqlViewList1 = new JList();
sqlViewScrollPane
.setViewportView(sqlViewList1);
sqlViewList1.setModel(sqlViewList1Model);
sqlViewList1
.setPreferredSize(new java.awt.Dimension(
214,
189));
}
}
{
userInputTextField = new JTextField();
studentQueryPanel1.add(userInputTextField);
userInputTextField
.setText("\u8bf7\u8f93\u5165\u67e5\u8be2\u4fe1\u606f");
userInputTextField.setBounds(231, 14, 112, 28);
}
{
dateInputTextField = new JTextField();
studentQueryPanel1.add(dateInputTextField);
dateInputTextField.setBounds(231, 56, 112, 28);
dateInputTextField
.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
dateInputTextFieldMouseClicked(evt);
}
});
}
{
queryByDateLabel = new JLabel();
studentQueryPanel1.add(queryByDateLabel);
queryByDateLabel.setBounds(168, 56, 56, 28);
queryByDateLabel.setText("\u65e5\u671f");
}
}
{
dataPanel = new JPanel();
stuMatchClassTabbedPane1.addTab(
"学生分配",
null,
dataPanel,
null);
dataPanel.setLayout(null);
{
StuInfoScrollPane = new JScrollPane();
dataPanel.add(StuInfoScrollPane);
StuInfoScrollPane.setBounds(21, 42, 343, 336);
{
StuInfoTableModel = new DefaultTableModel(
row,
columnStudent);
StuInfoTable = new JTable();
StuInfoScrollPane
.setViewportView(StuInfoTable);
StuInfoTable.setModel(StuInfoTableModel);
//设置学生信息表每个单元格的高度 StuInfoTable.setRowHeight(24);
StuInfoTable.setBounds(105, 385, 63, 28);
StuInfoTable.setPreferredSize(new java.awt.Dimension(322, 2142));
StuInfoTable.getTableHeader().setBounds(0, -133, 322, 21);
}
}
{
SelectButton = new JButton();
dataPanel.add(SelectButton);
SelectButton.setText("\u79fb\u52a8 >");
SelectButton.setBounds(385, 140, 77, 21);
SelectButton
.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
SelectButtonActionPerformed(evt);
}
});
}
{
DeleteButton = new JButton();
dataPanel.add(DeleteButton);
DeleteButton.setText("< \u5220\u9664");
DeleteButton.setBounds(385, 224, 77, 21);
DeleteButton
.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
DeleteButtonActionPerformed(evt);
}
});
}
{
StuInfoLabel = new JLabel();
dataPanel.add(StuInfoLabel);
StuInfoLabel.setText("\u53ef\u9009\u5b66\u751f\uff1a");
StuInfoLabel.setBounds(133, 14, 70, 28);
StuInfoLabel.setForeground(new java.awt.Color(0,0,255));
}
{
unselectedStuNumLabel1 = new JLabel();
dataPanel.add(unselectedStuNumLabel1);
unselectedStuNumLabel1.setText("0");
unselectedStuNumLabel1.setForeground(new java.awt.Color(
0,
0,
255));
unselectedStuNumLabel1.setBounds(203, 14, 56, 28);
}
{
jLabel1 = new JLabel();
dataPanel.add(jLabel1);
jLabel1.setText("\u4eba");
jLabel1.setForeground(new java.awt.Color(0,0,255));
jLabel1.setBounds(259, 14, 56, 28);
}
}
}
{
selectedStuNumLabel = new JLabel();
StuMatchClassPanel.add(selectedStuNumLabel);
selectedStuNumLabel.setText("0");
selectedStuNumLabel.setForeground(new java.awt.Color(0,0,255));
selectedStuNumLabel.setBounds(700, 56, 35, 28);
}
{
jLabel2 = new JLabel();
StuMatchClassPanel.add(jLabel2);
jLabel2.setText("\u4eba");
jLabel2.setForeground(new java.awt.Color(0, 0, 255));
jLabel2.setBounds(735, 56, 35, 28);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -