📄 scoupdateframe.java
字号:
package com.hb.studentmanager.ui;
import java.awt.BorderLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
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.ScoAction;
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 ScoUpdateFrame extends javax.swing.JDialog {
private JPanel UpdateScoPanel;
private JTextField testidTextField;
private JTextField stuidTextField;
private JTextField scoTextField;
private JButton okButton;
private JLabel scoLabel;
private JLabel tesLabel;
private JLabel stuLabel;
ScoAction sa=new ScoAction();
private int page;
private int row;
private JTable table;
public ScoUpdateFrame(JTable table,int row,int page) {
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-630)/2, (height-450)/2);
this.setModal(true);
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
getContentPane().setLayout(null);
this.setTitle("\u4fee\u6539\u6210\u7ee9");
{
UpdateScoPanel = new JPanel();
getContentPane().add(UpdateScoPanel);
UpdateScoPanel.setLayout(null);
UpdateScoPanel.setBounds(0, 0, 392, 268);
{
stuLabel = new JLabel();
UpdateScoPanel.add(stuLabel);
stuLabel.setText("\u5b66\u53f7\uff1a");
stuLabel.setBounds(56, 84, 77, 28);
}
{
tesLabel = new JLabel();
UpdateScoPanel.add(tesLabel);
tesLabel.setText("\u8003\u8bd5\u7f16\u53f7\uff1a");
tesLabel.setBounds(56, 28, 77, 28);
}
{
scoLabel = new JLabel();
UpdateScoPanel.add(scoLabel);
scoLabel.setText("\u79d1\u76ee\u6210\u7ee9\uff1a");
scoLabel.setBounds(56, 140, 77, 28);
}
{
okButton = new JButton();
UpdateScoPanel.add(okButton);
okButton.setText("\u63d0\u4ea4");
okButton.setBounds(252, 203, 63, 28);
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
}
{
String score=table.getValueAt(row,5).toString();//取值 scoTextField = new JTextField(score);
UpdateScoPanel.add(scoTextField);
scoTextField.setBounds(133, 140, 203, 28);
}
{
String tesid=table.getValueAt(row,0).toString();
testidTextField = new JTextField(tesid);
UpdateScoPanel.add(testidTextField);
testidTextField.setBounds(133, 28, 203, 28);
testidTextField.setEnabled(false);
}
{
String stuid=table.getValueAt(row,1).toString();
stuidTextField = new JTextField(stuid);
UpdateScoPanel.add(stuidTextField);
stuidTextField.setBounds(133, 84, 203, 28);
stuidTextField.setEnabled(false);
}
}
pack();
setSize(400, 300);
} catch (Exception e) {
e.printStackTrace();
}
}
private void okButtonActionPerformed(ActionEvent evt) {
String tesid=testidTextField.getText();
String stuid=stuidTextField.getText();
String score=scoTextField.getText();
if(sa.judgeupdate(tesid)==false)
JOptionPane.showMessageDialog(this,"没有科目,不能修改成绩!");
else{
if(score.equals(""))score="0";
if(score.matches("\\d{1,100}")==false||score.length()>1&&score.startsWith("0"))
JOptionPane.showMessageDialog(this,"分数输入有误!");
else if(Integer.parseInt(score)>100&&score.equals("")==false)
JOptionPane.showMessageDialog(this,"分数必须为0-100之间");
else {
int control=JOptionPane.showConfirmDialog(this, "真的要修改吗?","警告!",JOptionPane.OK_OPTION);
if(JOptionPane.OK_OPTION==control){
sa.update(tesid, stuid,score);
sa.init(table,page,5);
this.setVisible(false);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -