?? stupsycomquerydialog.java
字號(hào):
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;
//定義組合框查詢條件年、月、學(xué)習(xí)心理、學(xué)號(hào)姓名 // 定義ComboBox使用變量 周月查詢字段 private String[] combListDate = { "全部周", "全部月", "周", "月" };
// 定義ComboBox使用變量 學(xué)習(xí)心理查詢字段 private String[] combListStuPsy = { "全部評(píng)論","學(xué)習(xí)評(píng)論", "心理評(píng)論" };
// 定義Table使用變量 學(xué)生查詢字段 private String[] columnListStu = { "學(xué)號(hào)", "姓名"};
// 定義Table使用變量 學(xué)習(xí)/心理查詢字段 private String[] columnStuPsyQuery = { "年度", "周/月", "學(xué)號(hào)", "姓名", "心理評(píng)論",
"學(xué)習(xí)評(píng)論", "評(píng)論老師" };
// 判斷條件 private String[] comCompareList = { ">", "<", "=" };
//定義Table顯示變量 row
private String[][] row;
//定義學(xué)習(xí)\心理查詢表模式 private DefaultTableModel stuPsyTableModel;
// 定義nowYear變量,獲取當(dāng)前年 Date nowDate = new Date();
int nowYear = nowDate.getYear() + 1900;
//定義int型變量 nCommentType,1-全部評(píng)論、2-學(xué)習(xí)評(píng)論、3-心理評(píng)論 //初始化為1
int nCommentType = 1;
//是否查詢?nèi)吭路輇isWeekQuery,初始化為false
boolean bisWeekQuery = false;
// 定義SQL多條件查詢變量 public Vector vecSQL = new Vector(10);
// 定義學(xué)生查詢List顯示變量 vecListView
public Vector vecListView = new Vector(10);
// 定義學(xué)號(hào)正則表達(dá)式7位數(shù)字,第一位不能為空 public final static String REG_DIGIT = "[1-9]\\d{0,6}";
// 定義學(xué)生查詢條件數(shù)量初始化為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);
// 設(shè)置對(duì)話框居中 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(
"評(píng)論查詢",
null,
stuPsyQueryPanel,
null);
stuPsyQueryPanel.setPreferredSize(new java.awt.Dimension(567, 406));
stuPsyQueryPanel.setLayout(null);
{
String[] stryearTerm = new String[21];// 能查詢的年份為當(dāng)前年份的以前10年 int nextYear = 0;
//第一項(xiàng)查詢條件,查詢所有學(xué)期 stryearTerm[0] = "所有學(xué)期";
for (int i = nowYear - 9, j = 1; i <= nowYear
&& j < 21; i++) {
nextYear = i+1;
stryearTerm[j] = i + "~"+nextYear+"學(xué)年上學(xué)期";
stryearTerm[j+1] = i + "~"+nextYear+"學(xué)年下學(xué)期";
j+=2;
}
ComboBoxModel yearTermSelectComboBoxModel = new DefaultComboBoxModel(
stryearTerm);
yearTermSelectComboBoxModel.setSelectedItem( nowYear + "~"+(nowYear+1)+"學(xué)年上學(xué)期");
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(
"查詢結(jié)果",
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);
//設(shè)置心理學(xué)習(xí)評(píng)論查詢表格的高度 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
//心理\學(xué)習(xí)查詢年份 }
private void weekMonComboBoxActionPerformed(ActionEvent evt) {
//根據(jù)周\月選擇顯示周數(shù)、月數(shù) //用戶選擇組合框的Item索引 int nuserSelect = 0;
// 獲取用戶選擇字段 nuserSelect = this.weekMonComboBox.getSelectedIndex();
//組合框索引加一 nuserSelect ++;
//利用switch語句進(jìn)行判斷 switch(nuserSelect){
case 1:
//如果用戶選擇查詢?nèi)恐埽[藏1-18周 this.conditionComboBox.setVisible(false);
break;
case 2:
//如果用戶選擇查詢?nèi)吭?,隱藏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:
//如果用戶選擇查詢?cè)拢@示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, "周\\月號(hào):"+nuserSelect+"周\\月不存在.");
}
}
private void exitButtonActionPerformed(ActionEvent evt) {
//退出周\月學(xué)習(xí)\心理查詢 this.dispose();
}
/**
* 查詢周\月學(xué)習(xí)\心理評(píng)論 * @param evt
*/
private void searchButton1ActionPerformed(ActionEvent evt) {
//查詢周\月學(xué)習(xí)\心理評(píng)論 // 建立一個(gè)JDBC對(duì)象 JdbcConnct jdbcConnection = new JdbcConnct();
// 定義Vector變量,存儲(chǔ)從數(shù)據(jù)庫查詢來的信息 Vector vecData = new Vector();
//定義SQL語句 String strSQL = "";
//獲得SQL語句 strSQL = this.getUserSelect();
System.out.println("\nstrSQL:"+strSQL);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -