⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 examjdialog.java

📁 学生管理系统。使用java编程
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package com.hb.stumanagesys.basicinfomaintain;
import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import java.awt.BorderLayout;
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.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;

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.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SpinnerListModel;
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 ExamJDialog extends javax.swing.JDialog {
	private JPanel examPanel;//定义考试面板
	private JTextField presentNumTextField;//定义出席人数文本框
	private JScrollPane examScrollPane; //定义带滚动条的面板
	private JCheckBox misCheckBox;//定义复选框
	private JTextField dateTextField;
	private JLabel dateLabel2;
	private JLabel jLabel1;
	private JButton exitButton; //定义退出按钮
	private JTextField inputTextField; //定义输入条件的文本框
	private JSeparator examSeparator;
	private JButton submitButton; //定义提交按纽
	private JComboBox termComboBox; //定义学期选择的comboBox
	private JLabel anLabel;
	private JLabel presentNumLabel;
	private JLabel examPlaceLabel;
	private JTextField examPlaceTextField; //定义考试地点文本框
	private JTextField endTimeTextField; //定义结束时间文本框
	private JLabel endTimeLabel;
	private JButton querButton;//定义查询按纽
	private JButton deleteButton; //定义删除按纽
	private JButton commitButton; //定义编辑按纽
	private JButton addButton; //定义添加按纽
	private JTable examTable;
	private JScrollPane remarkScrollPane;//定义带滚动条的面板
	private JTextArea remarkTextArea; //定义备注文本域
	private JLabel remarkLabel;
	private JTextField teacherNameTextField;//定义老师名文本框
	private JLabel teacherNameLabel;
	private JComboBox examTypeComboBox;//定义考试性质ComboBox
	private JLabel examTypeLabel;
	private JTextField beginTimeTextField;//定义开始时间文本框
	private JLabel beginTimeLabel;
	private JTextField examIdTextField;//定义考试课程名文本框
	private JLabel examIdLabel;
	 DefaultTableModel  dataModel;  //定义表的模式
	 DefaultTableModel examTableModel;//定义表的模式

	/**
	 * 入口函数
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();//新建一个JFrame 用来构造对话框
		frame.setTitle("\u8003\u8bd5\u7ba1\u7406");
		ExamJDialog inst = new ExamJDialog(frame);//创建一个对话框
		inst.setVisible(true); //设置文本框可见
		inst.setLocationRelativeTo(null);  //设置此窗口相对于指定组件的位置
		inst.setResizable(false);
	}
	/**
	 * 对话框构造函数
	 * @param frame 
	 */
	public ExamJDialog(JFrame frame) {
		super(frame);
		initGUI();
	}
	/**
	 * 对话框界面的实现方法
	 *
	 */
	private void initGUI() {
		try {
			{
				this.setTitle("\u8003\u8bd5\u7ba1\u7406");
				getContentPane().setBackground(
					new java.awt.Color(185, 185, 255));
				getContentPane().setLayout(null);
				{
					showtablePanel1 = new JPanel();
					getContentPane().add(showtablePanel1);
					showtablePanel1.setLayout(null);
					showtablePanel1.setBackground(new java.awt.Color(185,185,255));
					showtablePanel1.setBounds(7, 0, 525, 448);
					{
						examScrollPane = new JScrollPane();
						showtablePanel1.add(examScrollPane);
						examScrollPane.setBounds(7, 77, 490, 322);
						{
							examTableModel = new DefaultTableModel(
								new String[][] {},
								new String[] { "考试号", "科目", "开始时间", "结束时间",
										"地点", "监考老师", "参考人数", "备注" });
							examTable = new JTable();
							examScrollPane.setViewportView(examTable);
							examTable.setModel(examTableModel);
							examTable.setBounds(70, 294, 455, 161);
							examTable.setDoubleBuffered(true);
							examTable.setDragEnabled(true);
							examTable.setFocusCycleRoot(true);
							examTable.setFocusTraversalKeysEnabled(false);
						}
					}
					{
						hSeparator1 = new JSeparator();
						showtablePanel1.add(hSeparator1);
						hSeparator1.setBounds(511, 7, 161, 406);
						hSeparator1.setOrientation(SwingConstants.VERTICAL);
					}
					{
						anLabel = new JLabel();
						showtablePanel1.add(anLabel);
						anLabel.setText("\u6309");
						anLabel.setBounds(7, 21, 28, 28);
					}
					{
						ComboBoxModel termComboBoxModel = new DefaultComboBoxModel(
							new String[] { "全部", "考试号", "科目", "考试日期", "开考时间",
									"结束时间", "考试性质", "监考老师" });
						termComboBox = new JComboBox();
						showtablePanel1.add(termComboBox);
						termComboBox.setModel(termComboBoxModel);
						termComboBox.setBounds(28, 21, 84, 28);
						termComboBox.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								termComboBoxActionPerformed(evt);
							}
						});
					}
					{
						ComboBoxModel comComboBoxModel = new DefaultComboBoxModel(
							new String[] { "大于", "等于", "小于" });
						comComboBox = new JComboBox();
						showtablePanel1.add(comComboBox);
						comComboBox.setModel(comComboBoxModel);
						comComboBox.setBounds(119, 21, 70, 28);
						comComboBox.setEnabled(false);
					}
					{
						inputTextField = new JTextField();
						showtablePanel1.add(inputTextField);
						inputTextField
							.setText("\u8bf7\u8f93\u5165\u67e5\u8be2\u6761\u4ef6");
						inputTextField.setBounds(196, 21, 119, 28);
						inputTextField.setEnabled(false);
					}
					{
						misCheckBox = new JCheckBox();
						showtablePanel1.add(misCheckBox);
						misCheckBox.setText("\u6a21\u7cca\u67e5\u8be2");
						misCheckBox.setBounds(322, 21, 77, 28);
						misCheckBox.setEnabled(false);
						misCheckBox.setBackground(new java.awt.Color(
							185,
							185,
							255));
						misCheckBox.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								misCheckBoxActionPerformed(evt);
							}
						});
					}
					{
						querButton = new JButton();
						showtablePanel1.add(querButton);
						querButton.setText("查询" + "");
						querButton.setBounds(406, 21, 63, 28);
						querButton.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								querButtonActionPerformed(evt);
							}
						});
					}
				}
				examPanel = new JPanel();
				getContentPane().add(examPanel);
				examPanel.setBackground(new java.awt.Color(185,185,255));
				examPanel.setLayout(null);
				examPanel.setBounds(525, 7, 378, 441);
				{
					examIdLabel = new JLabel();
					examPanel.add(examIdLabel);
					examIdLabel.setText("\u8bfe\u7a0b\u540d\uff1a");
					examIdLabel.setBounds(35, 21, 56, 21);
				}
				{
					examIdTextField = new JTextField();
					examPanel.add(examIdTextField);
					examIdTextField.setBounds(98, 21, 77, 28);
				}
				{
					beginTimeLabel = new JLabel();
					examPanel.add(beginTimeLabel);
					beginTimeLabel.setText("\u5f00\u8003\u65f6\u95f4");
					beginTimeLabel.setBounds(203, 63, 63, 28);
				}
				{
					beginTimeTextField = new JTextField();
					examPanel.add(beginTimeTextField);
					beginTimeTextField.setBounds(266, 63, 84, 28);
					//beginTimeTextField.setEnabled(false);
				}
				{
					endTimeLabel = new JLabel();
					examPanel.add(endTimeLabel);
					endTimeLabel.setText("\u7ed3\u675f\u65f6\u95f4");
					endTimeLabel.setBounds(203, 112, 63, 28);
				}
				{
					endTimeTextField = new JTextField();
					examPanel.add(endTimeTextField);
					endTimeTextField.setBounds(266, 112, 84, 28);

				}
				{
					examPlaceTextField = new JTextField();
					examPanel.add(examPlaceTextField);
					examPlaceTextField.setBounds(91, 182, 126, 28);
				}
				{
					examPlaceLabel = new JLabel();
					examPanel.add(examPlaceLabel);
					examPlaceLabel.setText("\u8003\u8bd5\u5730\u70b9");
					examPlaceLabel.setBounds(35, 182, 56, 28);
				}
				{
					presentNumLabel = new JLabel();
					examPanel.add(presentNumLabel);
					presentNumLabel.setText("\u53c2\u8003\u4eba\u6570");
					presentNumLabel.setBounds(35, 119, 63, 28);
				}
				{
					presentNumTextField = new JTextField();
					examPanel.add(presentNumTextField);
					presentNumTextField.setBounds(98, 119, 84, 28);
				}
				{
					examTypeLabel = new JLabel();
					examPanel.add(examTypeLabel);
					examTypeLabel.setText("\u8003\u8bd5\u6027\u8d28");
					examTypeLabel.setBounds(224, 182, 56, 28);
				}
				{
					ComboBoxModel examTypeComboBoxModel = new DefaultComboBoxModel(
						new String[] { "期中考试", "期末考试" });
					examTypeComboBox = new JComboBox();
					examPanel.add(examTypeComboBox);
					examTypeComboBox.setModel(examTypeComboBoxModel);
					examTypeComboBox.setBounds(280, 182, 77, 28);
				}
				{
					teacherNameLabel = new JLabel();
					examPanel.add(teacherNameLabel);
					teacherNameLabel.setText("\u76d1\u8003\u8001\u5e08");
					teacherNameLabel.setBounds(35, 70, 63, 28);
				}
				{
					teacherNameTextField = new JTextField();
					examPanel.add(teacherNameTextField);
					teacherNameTextField.setBounds(98, 70, 77, 28);
				}
				{
					remarkLabel = new JLabel();
					examPanel.add(remarkLabel);
					remarkLabel.setText("\u5907\u6ce8");
					remarkLabel.setBounds(35, 224, 63, 28);
				}
				{
					remarkScrollPane = new JScrollPane();
					examPanel.add(remarkScrollPane);
					remarkScrollPane.setBounds(91, 231, 140, 63);
					{
						remarkTextArea = new JTextArea();
						remarkScrollPane.setViewportView(remarkTextArea);
						remarkTextArea.setBounds(106, 234, 137, 60);
						remarkTextArea.setLineWrap(true);
					}
				}
				{
					addButton = new JButton();
					examPanel.add(addButton);
					addButton.setText("添加");
					addButton.setBounds(21, 336, 63, 28);
					addButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							addButtonActionPerformed(evt);
						}
					});
				}
				{
					commitButton = new JButton();
					examPanel.add(commitButton);
					commitButton.setText("\u4fee\u6539");
					commitButton.setBounds(91, 336, 63, 28);
					commitButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							commitButtonActionPerformed(evt);
						}
					});
				}
				{
					deleteButton = new JButton();
					examPanel.add(deleteButton);
					deleteButton.setText("\u5220\u9664");
					deleteButton.setBounds(161, 336, 63, 28);
					deleteButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							deleteButtonActionPerformed(evt);
						}
					});
				}
				{
					submitButton = new JButton();
					examPanel.add(submitButton);
					submitButton.setText("\u786e\u5b9a");
					submitButton.setBounds(231, 336, 63, 28);
					submitButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							submitButtonActionPerformed(evt);
						}
					});
				}
				{
					examSeparator = new JSeparator();
					examPanel.add(examSeparator);
					examSeparator.setBounds(14, 301, 336, 21);
				}
				{
					exitButton = new JButton();
					examPanel.add(exitButton);
					exitButton.setText("\u9000\u51fa");
					exitButton.setBounds(301, 336, 63, 28);
					exitButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							exitButtonActionPerformed(evt);
						}
					});
				}
				{
					jLabel1 = new JLabel();
					examPanel.add(jLabel1);
					jLabel1.setText("\u4f8b\uff1a10:00");
					jLabel1.setBounds(266, 84, 147, 35);
				}
				{
					dateLabel2 = new JLabel();
					examPanel.add(dateLabel2);
					dateLabel2.setText("\u8003\u8bd5\u65e5\u671f");
					dateLabel2.setBounds(203, 21, 63, 28);
				}
				{
					dateTextField = new JTextField();
					examPanel.add(dateTextField);
					dateTextField.setBounds(266, 21, 84, 28);
					dateTextField.setEditable(false);
					dateTextField.addMouseListener(new MouseAdapter() {
						public void mouseClicked(MouseEvent evt) {
							dateTextFieldMouseClicked(evt);
						}
					});
				}
			}
			this.setSize(900, 475);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 从文本框中获取课程的名称方法
	 * @return
	 */
	public String getCourseName(){
		//从课程名文本框中获取课程名称
		 String courseName = this.examIdTextField.getText().trim();
		 if(courseName.equals(""))
			 return null;
		 else{
			 return courseName;
		 }
	}
	/**
	 * 获取文本框中开始时间的方法
	 * @return
	 */
	public String getBeginTime()
	{
		//正则表达式,用来判断时间输入是否合法。
		String regex = "([0,1]?[0-9]{1}\\:[0-5][0-9]{1})||([2][0-4]{1}\\:[0-5][0-9]{1})";
		//从开始时间文本框中获取开始时间
		String beginTime = this.beginTimeTextField.getText().trim();
		//判断时间是否合法
		if(!beginTime.equals(""))//如果开始时间不为空,则判断是否合法
		{
			if(beginTime.matches(regex))
			{
				//合法则返回开始时间
				return beginTime;
					
			}
			else{
				//不合法则返回null
				return null;
			}
		}
		else //为空则返回null 
			return null;
		
	}
	/**
	 * 获取文本框中结束时间的方法
	 * @return
	 */
	
	public String getEndTime()
	{
		//正则表达式,用来判断时间输入是否合法
		String regex = "([0,1]?[0-9]{1}\\:[0-5][0-9]{1})||([2][0-4]{1}\\:[0-5][0-9]{1})";
		//从结束时间文本框中获取结束时间
		String endTime = this.endTimeTextField.getText().trim();
		if(!endTime.equals(""))//如果不为空,则判断是否合法
		{
			if(endTime.matches(regex))
			{
				//如果合法,则返回结束时间
				return  endTime;				
			}
			else //不合法,则返回null			
				return null;
		}			
		else //如果为空,则返回null
			return null;
	}
	/**
	 * 从文本框中获取老师名称的方法

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -