📄 subupdateframe.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.SubAction;/*** 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 SubUpdateFrame extends javax.swing.JDialog { private JPanel panel; private JLabel jLabel1; private JLabel classjLabel; private JComboBox jComboBox2; private JLabel jLabel2; private JLabel jLabel4; private JTextField jTextField2; private JTextField jTextField1; private JLabel showNameLabel; private JLabel jLabel3; private JButton button; private int page; private int row; private JTable table; private JLabel jLabel6; private JLabel jLabel5; private String subName=""; private String subScore=""; /** * Auto-generated main method to display this JFrame */ public SubUpdateFrame(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\u79d1\u76ee\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("\u79d1\u76ee\u4ee3\u53f7\uff1a"); jLabel1.setBounds(21, 28, 77, 14); } { classjLabel = new JLabel(); panel.add(classjLabel); classjLabel.setText("\u79d1\u76ee\u5b66\u5206\uff1a"); classjLabel.setBounds(21, 154, 70, 14); { ComboBoxModel jComboBox2Model = new DefaultComboBoxModel( new String[] { "Item One", "Item Two" }); jComboBox2 = new JComboBox(); classjLabel.add(jComboBox2); jComboBox2.setModel(jComboBox2Model); jComboBox2.setBounds(105, 105, 217, 21); } { jLabel2 = new JLabel(); classjLabel.add(jLabel2); jLabel2.setText("\u79d1\u76ee\u540d\u79f0\uff1a"); jLabel2.setBounds(21, 105, 70, 14); } } { button = new JButton(); panel.add(button); button.setText("\u63d0\u4ea4"); button.setBounds(301, 231, 63, 28); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { buttonActionPerformed(evt); } }); } { jLabel3 = new JLabel(); panel.add(jLabel3); jLabel3.setText("\u79d1\u76ee\u540d\u79f0\uff1a"); jLabel3.setBounds(21, 77, 70, 14); { jLabel4 = new JLabel(); jLabel3.add(jLabel4); jLabel4.setText("\u79d1\u76ee\u540d\u79f0\uff1a"); jLabel4.setBounds(21, 105, 70, 14); } } { String subId=(String)table.getValueAt(row,0); showNameLabel = new JLabel(); panel.add(showNameLabel); showNameLabel.setBounds(105, 21, 217, 28); showNameLabel.setText(subId); } { String subName=(String)table.getValueAt(row,1); String subSco=(String)table.getValueAt(row,2); if(subName!=null){ this.subName=subName; } if(subSco!=null){ this.subScore=subSco; } jTextField1 = new JTextField(subName); panel.add(jTextField1); jTextField1.setBounds(98, 70, 217, 28); jTextField2 = new JTextField(subSco); panel.add(jTextField2); jTextField2.setBounds(98, 147, 217, 28); } { 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(77, 105, 280, 28); } { jLabel6 = new JLabel(); panel.add(jLabel6); jLabel6.setText("\u6574\u6570\u6216\u8005\u7cbe\u5ea6\u4e3a\u4e00\u7684\u5c0f\u6570\uff0c\u6700\u5927\u503c\u4e3a9.9"); jLabel6.setForeground(java.awt.Color.lightGray); jLabel6.setBounds(84, 182, 238, 28); } } pack(); setSize(400, 300); } catch (Exception e) { e.printStackTrace(); } } private void buttonActionPerformed(ActionEvent evt) { int control; String subId=showNameLabel.getText(); String subName=jTextField1.getText(); String subSco=jTextField2.getText(); if(subName.getBytes().length>20){ JOptionPane.showMessageDialog(this,"至多输入20个字符,每个汉字或全角字符算2个字符!"); } else if(subSco.equals("")==false&&subSco.matches("\\d{1,2}+(\\.\\d{1})?")==false){ JOptionPane.showMessageDialog(this,"学分必须为整数或者精度为一的小数,学分最大为10"); } else if(subSco.equals("")==false&&Float.parseFloat(subSco)>10){ JOptionPane.showMessageDialog(this,"学分必须为整数或者精度为一的小数,学分最大为10"); } else if(this.subName.equals(subName)&&this.subScore.equals(subSco)){ control=JOptionPane.showConfirmDialog(this, "真的要修改吗?","警告!",JOptionPane.OK_OPTION); if(JOptionPane.OK_OPTION==control) this.setVisible(false); } else { control=JOptionPane.showConfirmDialog(this, "真的要修改吗?","警告!",JOptionPane.OK_OPTION); if(JOptionPane.OK_OPTION==control){ SubAction sa=new SubAction(); boolean flag=sa.subUpdate(subId, subName,subSco); if(flag==true){ sa.init(table,page,5); this.setVisible(false); } } } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -