📄 coursemagdialog.java
字号:
package com.hb.stumanagesys.basicinfomaintain;
import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import com.cloudgarden.resource.ArrayFocusTraversalPolicy;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
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.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.DefaultTableModel;
import com.hb.jdbcconnct.JdbcConnct;
import java.awt.BorderLayout;
/**
* 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 CourseMagDialog extends javax.swing.JDialog {
private JPanel CourseMagPanel;
private JTextField CourseNameTextField;
private JTextField PeriodTextField1;
private JTextField CreditHourTextField1;
private JTabbedPane CourseQueryTabbedPane;
private JLabel QueryConditionLabel;
private JButton ClearButton;
private JButton AddButton;
private JRadioButton OrRadioButton;
private JTextField EndTextField1;
private JTextField FirstTextField;
private JCheckBox SelectRageCheckBox;
private JList SQLComjList;
private JComboBox CompareComboBox;
private JPanel CourseQueryPane;
private JPanel CourseQueryPanel1;
private JSeparator CoursejSeparator2;
private JSeparator CoursejSeparator1;
private JButton ExitButton;
private JScrollPane CourseQueryScrollPane;
protected JTable CourseQueryTable; // 课程显示Table
private JButton QueryButton;
private JTextField QueryTextField;
private JComboBox CourseQueryComboBox1;
private ButtonGroup PreciFaintbuttonGroup;
private JRadioButton FaintnessRadioButton;
private JRadioButton PrecisionRadioButton;
private JLabel QueryLabel;
private JSeparator courseSeparator1;
private JButton SaveButton;
private JButton DeleteButton1;
private JButton ModifyButton1;
private JButton NewButton;
private JLabel CreditHourjLabel;
private JLabel PeriodLabel;
private JLabel CourseNameLabel;
private JTextField CourseIdTextField;
private JLabel CourseIdLabel;
// 定义默认表格模型 protected DefaultTableModel CourseQueryTableModel;
protected DefaultTableModel infoTable1Model;// 显示查询信息的表格模型
// 定义table表格使用变量,标题column[],数据row[]
private String[][] row;
private String[] column = { "科目号", "科目名", "学时", "学分" };
private String[] column1 = { "", "", "", "" };
// 定义ComboBox使用变量 查询字段 private String[] combList = { "科目号", "科目名", "学时", "学分" };
// 判断条件 private String[] comCompareList = { ">", "<", "=" };
// 定义List显示变量 vecListView
public Vector vecListView = new Vector(20);
// 定义SQL多条件查询变量 public Vector vecSQL = new Vector(20);
// 建立Course类对象 private Course course = new Course();
// 定义用户多字段查询数量,初始化为1
int ncount = 1;
// 判定输入格式,定义正则表达式 public final static String REG_DIGCOUID = "[1-9]\\d{0,6}";
public final static String REG_DIGPREIOD = "[1-9]\\d{0,2}";
public final static String REG_FLOATHOUR = "\\d{1}\\.?\\d{0,1}";
/**
* Auto-generated main method to display this JDialog
*/
public static void main(String[] args) {
JFrame frame = new JFrame();
CourseMagDialog inst = new CourseMagDialog(frame);
inst.setVisible(true);
inst.setLocationRelativeTo(null);
}
public CourseMagDialog(JFrame frame) {
super(frame);
initGUI();
// 初始化表格 try {
initTable();
} catch (SQLException e) {
e.printStackTrace();
}
}
private void initGUI() {
try {
{
BorderLayout thisLayout = new BorderLayout();
getContentPane().setLayout(thisLayout);
this.setTitle("\u5b66\u79d1\u4fe1\u606f\u7ba1\u7406");
{
{
PreciFaintbuttonGroup = new ButtonGroup();
}
CourseMagPanel = new JPanel();
getContentPane().add(CourseMagPanel, BorderLayout.CENTER);
CourseMagPanel.setBounds(0, 0, 900, 475);
CourseMagPanel.setBackground(new java.awt.Color(185, 185,
255));
CourseMagPanel.setLayout(null);
{
CourseIdLabel = new JLabel();
CourseMagPanel.add(CourseIdLabel);
CourseIdLabel.setText("\u79d1\u76ee\u53f7");
CourseIdLabel.setBounds(644, 42, 49, 28);
}
{
CourseIdTextField = new JTextField();
CourseMagPanel.add(CourseIdTextField);
CourseIdTextField.setText("\u79d1\u76ee\u53f7");
CourseIdTextField.setBounds(721, 42, 112, 28);
}
{
CourseNameLabel = new JLabel();
CourseMagPanel.add(CourseNameLabel);
CourseNameLabel.setText("\u79d1\u76ee\u540d");
CourseNameLabel.setBounds(644, 91, 49, 28);
}
{
CourseNameTextField = new JTextField();
CourseMagPanel.add(CourseNameTextField);
CourseNameTextField.setText("\u79d1\u76ee\u540d");
CourseNameTextField.setBounds(721, 91, 112, 28);
}
{
PeriodLabel = new JLabel();
CourseMagPanel.add(PeriodLabel);
PeriodLabel.setText("\u5b66\u65f6");
PeriodLabel.setBounds(644, 140, 49, 28);
}
{
CreditHourjLabel = new JLabel();
CourseMagPanel.add(CreditHourjLabel);
CreditHourjLabel.setText("\u5b66\u5206");
CreditHourjLabel.setBounds(644, 189, 49, 28);
}
{
PeriodTextField1 = new JTextField();
CourseMagPanel.add(PeriodTextField1);
PeriodTextField1.setBounds(721, 140, 112, 28);
PeriodTextField1
.setText("\u8bf7\u8f93\u5165\u5b66\u65f6");
}
{
CreditHourTextField1 = new JTextField();
CourseMagPanel.add(CreditHourTextField1);
CreditHourTextField1
.setText("\u8bf7\u8f93\u5165\u5b66\u5206");
CreditHourTextField1.setBounds(721, 189, 112, 28);
}
{
NewButton = new JButton();
CourseMagPanel.add(NewButton);
NewButton.setText("\u65b0\u589e");
NewButton.setBounds(651, 266, 70, 21);
NewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
NewButtonActionPerformed(evt);
}
});
}
{
ModifyButton1 = new JButton();
CourseMagPanel.add(ModifyButton1);
ModifyButton1.setText("\u4fee\u6539");
ModifyButton1.setBounds(763, 266, 70, 21);
ModifyButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ModifyButton1ActionPerformed(evt);
}
});
}
{
DeleteButton1 = new JButton();
CourseMagPanel.add(DeleteButton1);
DeleteButton1.setText("\u5220\u9664");
DeleteButton1.setBounds(651, 315, 70, 21);
DeleteButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
DeleteButton1ActionPerformed(evt);
}
});
}
{
SaveButton = new JButton();
CourseMagPanel.add(SaveButton);
SaveButton.setText("\u4fdd\u5b58");
SaveButton.setBounds(763, 315, 70, 21);
SaveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
try {
SaveButtonActionPerformed(evt);
} catch (SQLException e) {
e.printStackTrace();
}
}
});
}
{
courseSeparator1 = new JSeparator();
CourseMagPanel.add(courseSeparator1);
courseSeparator1.setBounds(14, 182, 476, -28);
}
{
ExitButton = new JButton();
CourseMagPanel.add(ExitButton);
ExitButton.setText("\u9000\u51fa");
ExitButton.setBounds(763, 392, 70, 21);
ExitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
ExitButtonActionPerformed(evt);
}
});
}
{
CoursejSeparator1 = new JSeparator();
CourseMagPanel.add(CoursejSeparator1);
CoursejSeparator1.setBounds(616, 0, 273, 448);
CoursejSeparator1
.setOrientation(SwingConstants.VERTICAL);
}
{
CoursejSeparator2 = new JSeparator();
CourseMagPanel.add(CoursejSeparator2);
CoursejSeparator2.setBounds(616, 350, 273, 98);
}
{
CourseQueryTabbedPane = new JTabbedPane();
CourseMagPanel.add(CourseQueryTabbedPane);
CourseQueryTabbedPane.setBounds(21, 14, 504, 399);
{
CourseQueryPane = new JPanel();
CourseQueryTabbedPane.addTab("学科查询", null,
CourseQueryPane, null);
CourseQueryPane
.setPreferredSize(new java.awt.Dimension(
497, 336));
CourseQueryPane.setLayout(null);
{
ComboBoxModel CourseQueryComboBox1Model = new DefaultComboBoxModel(
combList);
CourseQueryComboBox1 = new JComboBox();
CourseQueryPane.add(CourseQueryComboBox1);
CourseQueryComboBox1
.setModel(CourseQueryComboBox1Model);
CourseQueryComboBox1.setBounds(21, 14, 91, 28);
CourseQueryComboBox1
.addActionListener(new ActionListener() {
public void actionPerformed(
ActionEvent evt) {
CourseQueryComboBox1ActionPerformed(evt);
}
});
}
{
ComboBoxModel CompareComboBoxModel = new DefaultComboBoxModel(
comCompareList);
CompareComboBox = new JComboBox();
CourseQueryPane.add(CompareComboBox);
CompareComboBox.setModel(CompareComboBoxModel);
CompareComboBox.setBounds(126, 14, 91, 28);
CompareComboBox.setIgnoreRepaint(true);
}
{
ListModel SQLComjListModel = new DefaultComboBoxModel(
column1);
SQLComjList = new JList();
CourseQueryPane.add(SQLComjList);
SQLComjList.setModel(SQLComjListModel);
SQLComjList.setBounds(21, 161, 259, 154);
}
{
PrecisionRadioButton = new JRadioButton();
CourseQueryPane.add(PrecisionRadioButton);
PrecisionRadioButton.setText("\u65e0");
PrecisionRadioButton.setBounds(21, 112, 56, 21);
PreciFaintbuttonGroup.add(PrecisionRadioButton);
PrecisionRadioButton.setSelected(true);
PrecisionRadioButton
.addActionListener(new ActionListener() {
public void actionPerformed(
ActionEvent evt) {
PrecisionRadioButtonActionPerformed(evt);
}
});
}
{
FaintnessRadioButton = new JRadioButton();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -