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

📄 tesupdateframe.java

📁 包含了学生管理系统的一些基本操作以及相关窗口页面实现。
💻 JAVA
字号:
package com.hb.studentmanager.ui;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import com.hb.studentmanager.action.TesAction;


/**
* 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 TesUpdateFrame extends javax.swing.JDialog {
	private JPanel updatePanel;
	private JTextField tesTeaTextField;
	private JTextField tesAddTextField;
	private JLabel tesidLabel;
	private JLabel yearLabel;
	private JButton okButton;
	private JLabel minLabel;
	private JLabel hourLabel;
	private JLabel dayLabel;
	private JLabel monthLabel;
	private JLabel testeaLabel;
	private JLabel tesAddLabel;
	private JLabel tesdateLabel;
	private JLabel subidLabel;
	TesAction ta=new TesAction();
	private int page;
    private int row;
    private JTable table;
    private JComboBox subidComboBox;
    private JLabel jLabel111;
    private JTextField minTextField;
    private JTextField hourTextField;
    private JTextField dayTextField;
    private JTextField monthTextField;
    private JTextField yearTextField;
    private JTextField tesTextField;

	public TesUpdateFrame(JTable table,int row,int page) {
		super();
		this.row=row;
		this.page=page;
		this.table=table;
		initGUI();
		int width=Toolkit.getDefaultToolkit().getScreenSize().width+100;
		int height=Toolkit.getDefaultToolkit().getScreenSize().height+100;
		this.setLocation((width-630)/2, (height-450)/2);
		this.setModal(true);
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("\u4fee\u6539\u8003\u8bd5\u8868");
			{
				updatePanel = new JPanel();
				getContentPane().add(updatePanel);
				updatePanel.setLayout(null);
				updatePanel.setBounds(0, 0, 497, 357);
				{
					minLabel = new JLabel();
					updatePanel.add(minLabel);
					minLabel.setText("  \u5206");
					minLabel.setBounds(462, 140, 21, 28);
				}
				{
					tesidLabel = new JLabel();
					updatePanel.add(tesidLabel);
					tesidLabel.setText("\u8003\u8bd5\u7f16\u53f7\uff1a");
					tesidLabel.setBounds(28, 21, 105, 28);
				}
				{
					String tesid=table.getValueAt(row,0).toString();
					tesTextField = new JTextField(tesid);
					updatePanel.add(tesTextField);
					tesTextField.setBounds(133, 21, 322, 28);
					tesTextField.setEnabled(false);
				}
				{
					subidLabel = new JLabel();
					updatePanel.add(subidLabel);
					subidLabel.setText("\u79d1\u76ee\u4ee3\u53f7\uff1a");
					subidLabel.setBounds(28, 77, 105, 28);
				}
				{
					tesAddLabel = new JLabel();
					updatePanel.add(tesAddLabel);
					tesAddLabel.setText("\u8003\u8bd5\u5730\u70b9\uff1a");
					tesAddLabel.setBounds(28, 203, 105, 28);
				}
				{
					testeaLabel = new JLabel();
					updatePanel.add(testeaLabel);
					testeaLabel.setText("\u76d1\u8003\u8001\u5e08\uff1a");
					testeaLabel.setBounds(28, 259, 105, 28);
				}
				{
					okButton = new JButton();
					updatePanel.add(okButton);
					okButton.setText("\u63d0\u4ea4");
					okButton.setBounds(406, 315, 70, 28);
					okButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							okButtonActionPerformed(evt);
						}
					});
				}
				{
					hourLabel = new JLabel();
					updatePanel.add(hourLabel);
					hourLabel.setText(" \u65f6");
					hourLabel.setBounds(399, 140, 21, 28);
				}
				{
					dayLabel = new JLabel();
					updatePanel.add(dayLabel);
					dayLabel.setText(" \u65e5");
					dayLabel.setBounds(329, 140, 21, 28);
				}
				{
					monthLabel = new JLabel();
					updatePanel.add(monthLabel);
					monthLabel.setText(" \u6708");
					monthLabel.setBounds(259, 140, 21, 28);
				}
				{
					yearLabel = new JLabel();
					updatePanel.add(yearLabel);
					yearLabel.setText(" \u5e74");
					yearLabel.setBounds(189, 140, 21, 28);
				}
				{
					tesdateLabel = new JLabel();
					updatePanel.add(tesdateLabel);
					tesdateLabel.setText("\u8003\u8bd5\u65f6\u95f4\uff1a");
					tesdateLabel.setBounds(28, 140, 105, 28);
				}
				{
					String tesadd=table.getValueAt(row,3).toString();
					if(tesadd.equals(" "))tesadd="";
					tesAddTextField = new JTextField(tesadd);
					updatePanel.add(tesAddTextField);
					tesAddTextField.setBounds(133, 203, 343, 28);
				}
				{
					String testea=table.getValueAt(row,4).toString();
					if(testea.equals(" "))testea="";
					tesTeaTextField = new JTextField(testea);
					updatePanel.add(tesTeaTextField);
					tesTeaTextField.setBounds(133, 259, 343, 28);
				}
				{
					String y=table.getValueAt(row,2).toString().substring(0,4);
					if(y.equals("    "))y="";
					yearTextField = new JTextField(y);
					updatePanel.add(yearTextField);
					yearTextField.setBounds(133, 140, 56, 28);
				}
				{
					String m=table.getValueAt(row,2).toString().substring(5,7);
					if(m.equals("  "))m="";
					monthTextField = new JTextField(m);
					updatePanel.add(monthTextField);
					monthTextField.setBounds(210, 140, 49, 28);
				}
				{
					String d=table.getValueAt(row,2).toString().substring(8,10);
					if(d.equals("  "))d="";
					dayTextField = new JTextField(d);
					updatePanel.add(dayTextField);
					dayTextField.setBounds(280, 140, 49, 28);
				}
				{
					String h=table.getValueAt(row,2).toString().substring(11,13);
					if(h.equals("  "))h="";
					hourTextField = new JTextField(h);
					updatePanel.add(hourTextField);
					hourTextField.setBounds(350, 140, 49, 28);
				}
				{
					String mi=table.getValueAt(row,2).toString().substring(14,16);
					if(mi.equals("  "))mi="";
					minTextField = new JTextField(mi);
					updatePanel.add(minTextField);
					minTextField.setBounds(420, 140, 49, 28);
				}
				{
					jLabel111 = new JLabel();
					updatePanel.add(jLabel111);
					jLabel111.setText("   *");
					jLabel111.setBounds(455, 21, 21, 28);
				}
				{
					ComboBoxModel subidComboBoxModel = new DefaultComboBoxModel();
					subidComboBox = new JComboBox();
					updatePanel.add(subidComboBox);
					subidComboBox.setModel(subidComboBoxModel);
					subidComboBox.setBounds(133, 77, 336, 28);
					String subid=table.getValueAt(row,1).toString();
					if(subid.equals(" "))subid="";
					ta.subid(subidComboBox,subid);
				}
			}
			pack();
			this.setSize(505, 389);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void okButtonActionPerformed(ActionEvent evt) {
		int flag=0;
		int d;
		String tesid=tesTextField.getText();
		String subid=subidComboBox.getSelectedItem().toString();

		String year=yearTextField.getText();
		String month=monthTextField.getText();
		String day=dayTextField.getText();
		String hour=hourTextField.getText();
		String min=minTextField.getText();
		String tesdate=year+"-"+month+"-" +day+"-"+hour+"-"+min;
		
		String tesadd=tesAddTextField.getText();
		String testea=tesTeaTextField.getText();

		if(tesdate.equals("----"))tesdate="";//考试时间错误
		else {
			  if(tesdate.matches("\\d{4}-\\d{1,2}-\\d{1,2}-\\d{1,2}-\\d{1,2}")==false){
			      JOptionPane.showMessageDialog(this, "考试时间输入格式有误!格式为'2008-08-08-08-08'");
			      flag=1;
			  }
			
	    	  else{
	    		  if(Integer.parseInt(month)<1||Integer.parseInt(month)>12){
			         JOptionPane.showMessageDialog(this, "月大小必须在1-12之间");
			         flag=1;
	    		  }
	    		  else{ 
		        	  d=ta.mdays(Integer.parseInt(year),Integer.parseInt(month));
		              if(Integer.parseInt(day)<1||Integer.parseInt(day)>d){
			            JOptionPane.showMessageDialog(this, "该月天数必须在1-"+d+"之间");
			            flag=1;
		              }
		             else if(Integer.parseInt(hour)<1||Integer.parseInt(hour)>12){
			            JOptionPane.showMessageDialog(this, "小时大小必须在1-12之间");
			           flag=1;
		             }
			
		             else if(Integer.parseInt(min)<0||Integer.parseInt(min)>59){
			            JOptionPane.showMessageDialog(this, "分钟大小必须在0-59之间");
                        flag=1;
		             }
	    		  }
	    	  }
		}  //考试时间错误
		
	    if(flag==0)	{
            if(tesadd.getBytes().length>20)
			     JOptionPane.showMessageDialog(this,"地址长度不能超过20!");
		
	          else if(testea.getBytes().length>20)
			     JOptionPane.showMessageDialog(this,"监考人员长度不能超过20!");
	          else{
			    int control=JOptionPane.showConfirmDialog(this, "真的要修改吗?","警告!",JOptionPane.OK_OPTION);
			    if(JOptionPane.OK_OPTION==control){
		           ta.update(tesid,subid,tesdate,tesadd,testea);
		           ta.init(table,page,5);
		           this.setVisible(false);
			    }
		      }
	   }
	}
}

⌨️ 快捷键说明

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