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

📄 speupdateframe.java

📁 包含了学生管理系统的一些基本操作以及相关窗口页面实现。
💻 JAVA
字号:
package com.hb.studentmanager.ui;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.KeyAdapter;import java.awt.event.KeyEvent;import javax.swing.JButton;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.SpeAction;/*** 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 SpeUpdateFrame extends javax.swing.JDialog {	private JPanel panel;	private JLabel jLabel1;	private JLabel classjLabel;	private JLabel showLabel;	private JTextField textField1;	private JButton button;	private int page;    private int row;    private JTable table;    private JLabel jLabel5;    private String speName="";	/**	* Auto-generated main method to display this JFrame	*/	public SpeUpdateFrame(int row,int page,JTable table) {		super();		this.row=row;		this.page=page;		this.table=table;		initGUI();		int width=Toolkit.getDefaultToolkit().getScreenSize().width;		int height=Toolkit.getDefaultToolkit().getScreenSize().height;		this.setLocation((width-400)/2, (height-300)/2);		this.setModal(true);	}		private void initGUI() {		try {			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);			getContentPane().setLayout(null);			this.setTitle("\u4fee\u6539\u4e13\u4e1a\u4fe1\u606f");			{				panel = new JPanel();				getContentPane().add(panel);				panel.setBounds(0, 0, 392, 273);				panel.setLayout(null);				{					jLabel1 = new JLabel();					panel.add(jLabel1);					jLabel1.setText("\u4e13\u4e1a\u4ee3\u53f7\uff1a");					jLabel1.setBounds(21, 42, 77, 14);				}				{					classjLabel = new JLabel();					panel.add(classjLabel);					classjLabel.setText("\u4e13\u4e1a\u540d\u79f0\uff1a");					classjLabel.setBounds(21, 98, 70, 14);				}				{					button = new JButton();					panel.add(button);					button.setText("\u63d0\u4ea4");					button.setBounds(287, 203, 63, 28);					button.addKeyListener(new KeyAdapter() {						public void keyReleased(KeyEvent evt) {							buttonKeyReleased(evt);						}						public void keyTyped(KeyEvent evt) {							buttonKeyTyped(evt);						}						public void keyPressed(KeyEvent evt) {							buttonKeyPressed(evt);						}					});					button.addActionListener(new ActionListener() {						public void actionPerformed(ActionEvent evt) {							buttonActionPerformed(evt);						}					});				}				{					String speId=(String)table.getValueAt(row,0);					showLabel = new JLabel();					panel.add(showLabel);					showLabel.setBounds(98, 35, 210, 28);					showLabel.setText(speId);				}				{					String speName=(String)table.getValueAt(row,1);					if(speName!=null)					this.speName=speName;					textField1 = new JTextField(speName);					panel.add(textField1);					textField1.setBounds(98, 91, 210, 28);					textField1.addKeyListener(new KeyAdapter() {						public void keyTyped(KeyEvent evt) {							textField1KeyTyped(evt);						}						public void keyReleased(KeyEvent evt) {							textField1KeyReleased(evt);						}						public void keyPressed(KeyEvent evt) {							textField1KeyPressed(evt);						}					});				}				{					jLabel5 = new JLabel();					panel.add(jLabel5);					jLabel5						.setText("1-20\u4e2a\u5b57\u7b26\uff0c\u6bcf\u4e2a\u6c49\u5b57\u6216\u5168\u89d2\u5b57\u7b26\u7b972\u4e2a\u5b57\u7b26");					jLabel5.setForeground(java.awt.Color.lightGray);					jLabel5.setBounds(84, 119, 280, 28);				}			}			pack();			setSize(400, 300);		} catch (Exception e) {			e.printStackTrace();		}	}		private void buttonActionPerformed(ActionEvent evt) {		buttonAction();	}		private void buttonKeyPressed(KeyEvent evt) {		key_press_event(evt);	}		private void buttonKeyTyped(KeyEvent evt) {}		private void buttonKeyReleased(KeyEvent evt) {}		private void textField1KeyPressed(KeyEvent evt) {		key_press_event(evt);	}		private void textField1KeyReleased(KeyEvent evt) {}		private void textField1KeyTyped(KeyEvent evt) {}	public void key_press_event(KeyEvent e) {		if (e.getKeyCode() == KeyEvent.VK_ENTER){			buttonAction();		}	}	public void buttonAction(){		String speId=showLabel.getText();		String speName=textField1.getText();		int control;		boolean flag=true;	    if(speId.length()!=5||speId.substring(0, 3).equals("spe")==false||speId.substring(3).matches("\\d{2}")==false){			JOptionPane.showMessageDialog(this,"请输入正确的专业代号,专业代号格式为:spe+两位数字");			flag=false;		}	    if(speName.getBytes().length>20&&flag==true){	    	JOptionPane.showMessageDialog(this,"至多输入20个字符,每个汉字或全角字符算2个字符!");	    	flag=false;	    }	    else if(this.speName.equals(speName)&&flag==true){	    	control=JOptionPane.showConfirmDialog(this, "真的要修改吗?","警告!",JOptionPane.OK_OPTION);	    	if(JOptionPane.OK_OPTION==control)	    		this.setVisible(false);	    }		else if(flag==true){			control=JOptionPane.showConfirmDialog(this, "真的要修改吗?","警告!",JOptionPane.OK_OPTION);			if(JOptionPane.OK_OPTION==control){				SpeAction sa=new SpeAction();				flag=sa.speUpdate(speId, speName);				if(flag==true){					sa.init(table,page,5);					this.setVisible(false);					}		}		}	}}

⌨️ 快捷键说明

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