📄 addchengjiframe.java
字号:
package edu.xscj.business;
import javax.swing.*;
import java.awt.BorderLayout;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.util.*;
import edu.xscj.action.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import edu.xscj.bean.*;
import edu.xscj.action.*;
public class AddChengjiFrame extends JFrame {
public AddChengjiFrame() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
lbStuNo.setText("学号");
this.getContentPane().setLayout(xYLayout1);
lbCourNo.setText("课程号");
lbChengji.setText("成绩");
btnOK.setText("确定");
btnOK.addActionListener(new AddChengjiFrame_btnOK_actionAdapter(this));
chengji.stuNoCourNo();
Iterator stuNo = chengji.getStuNoCollect().iterator();
Iterator courNo = chengji.getCourNoCollect().iterator();
while (stuNo.hasNext()) {
boxStuNo.addItem(stuNo.next());
} while (courNo.hasNext()) {
boxCourNo.addItem(courNo.next());
}
this.getContentPane().add(boxCourNo,
new XYConstraints(187, 106, 102, 25));
this.getContentPane().add(lbStuNo, new XYConstraints(120, 55, 33, 22));
this.getContentPane().add(boxStuNo, new XYConstraints(187, 53, 102, 26));
this.getContentPane().add(lbCourNo, new XYConstraints(115, 112, -1, -1));
this.getContentPane().add(lbChengji, new XYConstraints(121, 169, -1, -1));
this.getContentPane().add(txtChengji,
new XYConstraints(187, 162, 101, 27));
this.getContentPane().add(btnOK, new XYConstraints(174, 226, 71, 27));
this.setSize(420, 350);
this.setResizable(false);
this.setTitle("添加成绩");
}
JLabel lbStuNo = new JLabel();
XYLayout xYLayout1 = new XYLayout();
JComboBox boxStuNo = new JComboBox();
JLabel lbCourNo = new JLabel();
JComboBox boxCourNo = new JComboBox();
JLabel lbChengji = new JLabel();
JTextField txtChengji = new JTextField();
JButton btnOK = new JButton();
StuNoCourNoAction chengji = new StuNoCourNoAction();
public void btnOK_actionPerformed(ActionEvent e) {
String stuNo = (String) boxStuNo.getSelectedItem();
String courNo = (String) boxCourNo.getSelectedItem();
if (txtChengji.getText() == null || txtChengji.getText().equals("")) {
JOptionPane.showMessageDialog(this, "成绩不能为空!", "温心提示",
JOptionPane.
INFORMATION_MESSAGE);
return;
}
int chengji = 0;
try {
chengji = Integer.parseInt(txtChengji.getText());
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, "成绩只能为数字!", "温心提示",
JOptionPane.
INFORMATION_MESSAGE);
return;
}
Chengji chj = new Chengji();
chj.setStuNo(stuNo);
chj.setCourNo(courNo);
chj.setStuCourGrade(chengji);
AddChengjiAction addChengjiaction = new AddChengjiAction();
String str = addChengjiaction.addCourse(chj);
if (str.equals("sucess")) {
JOptionPane.showMessageDialog(this, "添加成绩成功!", "温心提示",
JOptionPane.
INFORMATION_MESSAGE);
} else if (str.equals("failer")) {
JOptionPane.showMessageDialog(this, "添加成绩失败!!", "温心提示",
JOptionPane.
INFORMATION_MESSAGE);
}
}
}
class AddChengjiFrame_btnOK_actionAdapter implements ActionListener {
private AddChengjiFrame adaptee;
AddChengjiFrame_btnOK_actionAdapter(AddChengjiFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnOK_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -