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

📄 stupsycomquerydialog.java

📁 学生管理系统。使用java编程
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.hb.stumanagesys.stutinfomag;
import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import com.hb.jdbcconnct.JdbcConnct;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.Date;
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.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.table.DefaultTableModel;
import javax.swing.table.TableModel;

/**
* 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 stuPsyComQueryDialog extends javax.swing.JDialog {
	private JTabbedPane StuPsyTabbedPane;
	private JPanel stuPsyQueryPanel;
	private JComboBox yearTermSelectComboBox;
	private JComboBox compareComboBox;
	private ButtonGroup querybuttonGroup;
	private JButton addQueryButton;
	private JButton ClearButton;
	private JList studentQueryList1;
	private JRadioButton orRadioButton1;
	private JRadioButton andRadioButton1;
	private JRadioButton nullRadioButton1;
	private JButton exitButton;
	private JTable stuPsyTable;
	private JButton searchButton;
	private JLabel queryViewLabel;
	private JScrollPane stuPsyScrollPane;
	private JTextField userInputTextField;
	private JComboBox queryConditionComboBox;
	private JComboBox stuPsyComboBox;
	private JComboBox conditionComboBox;
	private JComboBox weekMonComboBox;
	private JPanel dataViewPanel;
	//定义组合框查询条件年、月、学习心理、学号姓名	// 定义ComboBox使用变量 周月查询字段	private String[] combListDate = { "全部周", "全部月", "周", "月" };

	// 定义ComboBox使用变量 学习心理查询字段	private String[] combListStuPsy = { "全部评论","学习评论", "心理评论" };

	// 定义Table使用变量 学生查询字段	private String[] columnListStu = { "学号", "姓名"};
	
	// 定义Table使用变量 学习/心理查询字段	private String[] columnStuPsyQuery = {  "年度", "周/月", "学号", "姓名", "心理评论",
			"学习评论", "评论老师" };
	// 判断条件	private String[] comCompareList = { ">", "<", "=" };
	
	//定义Table显示变量 row
	private String[][] row;
	
	//定义学习\心理查询表模式	private DefaultTableModel stuPsyTableModel;
	
	// 定义nowYear变量,获取当前年	Date nowDate = new Date();

	int nowYear = nowDate.getYear() + 1900;	
	
	//定义int型变量 nCommentType,1-全部评论、2-学习评论、3-心理评论	//初始化为1
	int nCommentType  = 1;
	//是否查询全部月份bisWeekQuery,初始化为false
	boolean  bisWeekQuery = false;
	
	// 定义SQL多条件查询变量	public Vector vecSQL = new Vector(10);

	// 定义学生查询List显示变量 vecListView
	public Vector vecListView = new Vector(10);
	
	// 定义学号正则表达式7位数字,第一位不能为空	public final static String REG_DIGIT = "[1-9]\\d{0,6}";
	// 定义学生查询条件数量初始化为1
	int ncount = 1;

	/**
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		stuPsyComQueryDialog inst = new stuPsyComQueryDialog(frame);
		inst.setVisible(true);
		// 设置对话框居中		inst.setLocationRelativeTo(null);
	}
	
	public stuPsyComQueryDialog(JFrame frame) {
		super(frame);
		initGUI();
	}
	
	private void initGUI() {
		try {
			{
				getContentPane().setLayout(null);
				this.setTitle("\u5468\\\u5b66\u4e60\\\u7406\u8bc4\u8bba\u67e5\u8be2");
				getContentPane().setForeground(new java.awt.Color(185,185,255));
				{
					{
						querybuttonGroup = new ButtonGroup();
					}
					StuPsyTabbedPane = new JTabbedPane();
					getContentPane().add(StuPsyTabbedPane);
					StuPsyTabbedPane.setBounds(21, 0, 574, 434);
					{
						stuPsyQueryPanel = new JPanel();
						StuPsyTabbedPane.addTab(
							"评论查询",
							null,
							stuPsyQueryPanel,
							null);
						stuPsyQueryPanel.setPreferredSize(new java.awt.Dimension(567, 406));
						stuPsyQueryPanel.setLayout(null);
						{
							String[] stryearTerm = new String[21];// 能查询的年份为当前年份的以前10年							int nextYear = 0;
							//第一项查询条件,查询所有学期							stryearTerm[0] = "所有学期";
							for (int i = nowYear - 9, j = 1; i <= nowYear 
									&& j < 21; i++) {
								nextYear = i+1;
								stryearTerm[j] = i + "~"+nextYear+"学年上学期";
								stryearTerm[j+1] = i + "~"+nextYear+"学年下学期";
								j+=2;
							}

							ComboBoxModel yearTermSelectComboBoxModel = new DefaultComboBoxModel(
									stryearTerm);
							yearTermSelectComboBoxModel.setSelectedItem( nowYear + "~"+(nowYear+1)+"学年上学期");
							yearTermSelectComboBox = new JComboBox();
							stuPsyQueryPanel.add(yearTermSelectComboBox);
							yearTermSelectComboBox
									.setModel(yearTermSelectComboBoxModel);
							yearTermSelectComboBox.setBounds(28, 21, 168, 21);
							yearTermSelectComboBox
									.addActionListener(new ActionListener() {
										public void actionPerformed(
												ActionEvent evt) {
											yearTermSelectComboBoxActionPerformed(evt);
										}
								});
						}
						{
							ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(
									combListDate);
							weekMonComboBox = new JComboBox();
							stuPsyQueryPanel.add(weekMonComboBox);
							weekMonComboBox.setModel(jComboBox1Model);
							weekMonComboBox.setBounds(217, 21, 70, 21);
							weekMonComboBox
								.addActionListener(new ActionListener() {
								public void actionPerformed(ActionEvent evt) {
									weekMonComboBoxActionPerformed(evt);
								}
								});
						}
						{
							ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(
									);
							conditionComboBox = new JComboBox();
							stuPsyQueryPanel.add(conditionComboBox);
							conditionComboBox.setModel(jComboBox1Model);
							conditionComboBox.setBounds(308, 21, 70, 21);
						}
						{
							ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(
									combListStuPsy);
							stuPsyComboBox = new JComboBox();
							stuPsyQueryPanel.add(stuPsyComboBox);
							stuPsyComboBox.setModel(jComboBox1Model);
							stuPsyComboBox.setBounds(28, 56, 70, 21);
						}
						{
							ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(
									columnListStu);
							queryConditionComboBox = new JComboBox();
							stuPsyQueryPanel.add(queryConditionComboBox);
							queryConditionComboBox.setModel(jComboBox1Model);
							queryConditionComboBox.setBounds(126, 56, 70, 21);
							queryConditionComboBox
								.addActionListener(new ActionListener() {
								public void actionPerformed(ActionEvent evt) {
									queryConditionComboBoxActionPerformed(evt);
								}
								});
						}
						{
							userInputTextField = new JTextField();
							stuPsyQueryPanel.add(userInputTextField);
							userInputTextField.setText("\u8bf7\u8f93\u5165\u67e5\u8be2\u4fe1\u606f");
							userInputTextField.setBounds(308, 49, 112, 28);
						}
						{
							searchButton = new JButton();
							stuPsyQueryPanel.add(searchButton);
							searchButton.setText("\u67e5\u8be2");
							searchButton.setBounds(28, 364, 70, 21);
							searchButton
								.addActionListener(new ActionListener() {
								public void actionPerformed(ActionEvent evt) {
									searchButton1ActionPerformed(evt);
								}
								});
						}
						{
							exitButton = new JButton();
							stuPsyQueryPanel.add(exitButton);
							exitButton.setText("\u9000\u51fa");
							exitButton.setBounds(462, 357, 63, 28);
							exitButton.addActionListener(new ActionListener() {
								public void actionPerformed(ActionEvent evt) {
									exitButtonActionPerformed(evt);
								}
							});
						}
						{
							nullRadioButton1 = new JRadioButton();
							stuPsyQueryPanel.add(nullRadioButton1);
							nullRadioButton1.setText("\u65e0");
							nullRadioButton1.setSelected(true);
							nullRadioButton1.setBounds(28, 98, 70, 21);
							querybuttonGroup.add(nullRadioButton1);
						}
						{
							andRadioButton1 = new JRadioButton();
							stuPsyQueryPanel.add(andRadioButton1);
							andRadioButton1.setText("\u5e76\u4e14");
							andRadioButton1.setBounds(98, 98, 70, 21);
							querybuttonGroup.add(andRadioButton1);
						}
						{
							orRadioButton1 = new JRadioButton();
							stuPsyQueryPanel.add(orRadioButton1);
							orRadioButton1.setText("\u6216\u8005");
							orRadioButton1.setBounds(168, 98, 70, 21);
							querybuttonGroup.add(orRadioButton1);
						}
						{
							ListModel studentQueryList1Model = new DefaultComboBoxModel(
								);
							studentQueryList1 = new JList();
							stuPsyQueryPanel.add(studentQueryList1);
							studentQueryList1.setModel(studentQueryList1Model);
							studentQueryList1.setBounds(28, 133, 224, 196);
						}
						{
							ClearButton = new JButton();
							stuPsyQueryPanel.add(ClearButton);
							ClearButton.setText("\u6e05\u7a7a");
							ClearButton.setBounds(105, 364, 70, 21);
							ClearButton.addActionListener(new ActionListener() {
								public void actionPerformed(ActionEvent evt) {
									ClearButtonActionPerformed(evt);
								}
							});
						}
						{
							addQueryButton = new JButton();
							stuPsyQueryPanel.add(addQueryButton);
							addQueryButton.setText("\u589e\u52a0");
							addQueryButton.setBounds(189, 364, 70, 21);
							addQueryButton.addActionListener(new ActionListener() {
								public void actionPerformed(ActionEvent evt) {
									addButton1ActionPerformed(evt);
								}
							});
						}
						{
							ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(
									comCompareList);
							compareComboBox = new JComboBox();
							stuPsyQueryPanel.add(compareComboBox);
							compareComboBox.setModel(jComboBox1Model);
							compareComboBox.setBounds(217, 56, 70, 21);
						}
					}
					{
						dataViewPanel = new JPanel();
						StuPsyTabbedPane.addTab(
							"查询结果",
							null,
							dataViewPanel,
							null);
						dataViewPanel.setLayout(null);
						{
							stuPsyScrollPane = new JScrollPane();
							dataViewPanel.add(stuPsyScrollPane);
							stuPsyScrollPane.setBounds(28, 56, 504, 329);
							{
								DefaultTableModel stuPsyTableModel = new DefaultTableModel(
									row,
									columnStuPsyQuery);
								stuPsyTable = new JTable();
								stuPsyTable.setLayout(null);
								stuPsyScrollPane.setViewportView(stuPsyTable);
								stuPsyTable.setModel(stuPsyTableModel);
								//设置心理学习评论查询表格的高度								stuPsyTable.setRowHeight(24);
								stuPsyTable.setPreferredSize(new java.awt.Dimension(483, 378));
								stuPsyTable.getTableHeader().setPreferredSize(
									new java.awt.Dimension(494, 21));
								stuPsyTable.getTableHeader().setBounds(
									0,
									0,
									494,
									21);
							}
						}
						{
							queryViewLabel = new JLabel();
							dataViewPanel.add(queryViewLabel);
							queryViewLabel.setText("\u67e5\u8be2\u663e\u793a");
							queryViewLabel.setBounds(70, 14, 399, 28);
							queryViewLabel.setFont(new java.awt.Font("宋体",0,14));
							queryViewLabel.setForeground(new java.awt.Color(0,0,255));
						}
					}
				}
			}
			setSize(625, 475);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void yearTermSelectComboBoxActionPerformed(ActionEvent evt) {
		//TODO add your code for yearTermSelectComboBox.actionPerformed
		//心理\学习查询年份	}
	
	private void weekMonComboBoxActionPerformed(ActionEvent evt) {
		//根据周\月选择显示周数、月数		//用户选择组合框的Item索引		int nuserSelect = 0;
		// 获取用户选择字段		nuserSelect = this.weekMonComboBox.getSelectedIndex();
		//组合框索引加一		nuserSelect ++;

		
		//利用switch语句进行判断		switch(nuserSelect){
		case 1:
			//如果用户选择查询全部周,隐藏1-18周			this.conditionComboBox.setVisible(false);			
			
			break;
		case 2:
			//如果用户选择查询全部月	,隐藏1-4月			this.conditionComboBox.setVisible(false);
			
			break;
		case 3:
			//如果用户选择查询周,显示1-18周并为其赋值			//清空周选择组合框			this.conditionComboBox.setVisible(true);
			this.conditionComboBox.removeAllItems();
			for(int i = 1 ; i <= 18 ; i++ ){
				this.conditionComboBox.addItem("第"+i+"周");
			}			
			
			break;
		case 4:
			//如果用户选择查询月,显示1-4月并为其赋值			this.conditionComboBox.setVisible(true);
			this.conditionComboBox.removeAllItems();
			for(int i = 1 ; i <= 4 ; i++ ){
				this.conditionComboBox.addItem("第"+i+"月");
			}
			
			break;
		default:
			JOptionPane.showMessageDialog(this, "周\\月号:"+nuserSelect+"周\\月不存在.");
		}
		
	}
	
	private void exitButtonActionPerformed(ActionEvent evt) {
		//退出周\月学习\心理查询		this.dispose();
	}
	
	/**
	 * 查询周\月学习\心理评论	 * @param evt
	 */
	private void searchButton1ActionPerformed(ActionEvent evt) {
		//查询周\月学习\心理评论		// 建立一个JDBC对象		JdbcConnct jdbcConnection = new JdbcConnct();
		// 定义Vector变量,存储从数据库查询来的信息		Vector vecData = new Vector();
		//定义SQL语句		String strSQL = "";
		
		//获得SQL语句		strSQL = this.getUserSelect();
		System.out.println("\nstrSQL:"+strSQL);

⌨️ 快捷键说明

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