?? addcourseframe.java~31~
字號:
package edu.xscj.business;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import edu.xscj.bean.*;
import edu.xscj.action.*;
public class addCourseFrame extends JFrame {
public addCourseFrame() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
lbCourseNo.setText("課程編號");
lbCourseName.setText("課程名");
lbXuefen.setText("學分");
btnSubmit.setText("確認");
btnSubmit.addActionListener(new addCourseFrame_btnSubmit_actionAdapter(this));
btnReset.setText("重填");
for (int i = 1; i < 20; i++) {
boxXuefen.addItem(Integer.toString(i));
}
this.getContentPane().add(lbCourseNo, new XYConstraints(75, 35, 53, 24));
this.getContentPane().add(lbCourseName,
new XYConstraints(81, 90, -1, -1));
this.getContentPane().add(txtCourseNo,
new XYConstraints(159, 35, 115, 25));
this.getContentPane().add(txtCourseName,
new XYConstraints(159, 85, 115, 24));
this.getContentPane().add(lbXuefen, new XYConstraints(87, 139, -1, -1));
this.getContentPane().add(btnSubmit, new XYConstraints(99, 208, 63, 26));
this.getContentPane().add(btnReset, new XYConstraints(211, 209, -1, -1));
this.getContentPane().add(boxXuefen,
new XYConstraints(159, 135, 75, 22));
}
XYLayout xYLayout1 = new XYLayout();
JLabel lbCourseNo = new JLabel();
JTextField txtCourseNo = new JTextField();
JLabel lbCourseName = new JLabel();
JTextField txtCourseName = new JTextField();
JLabel lbXuefen = new JLabel();
JButton btnSubmit = new JButton();
JButton btnReset = new JButton();
JComboBox boxXuefen = new JComboBox();
public void btnSubmit_actionPerformed(ActionEvent e) {
String courseNo = txtCourseNo.getText();
String courseName = txtCourseName.getText();
String xuefen = (String) boxXuefen.getSelectedItem();
Course course = new Course();
course.setCourNo(courseNo);
course.setCourName(courseName);
course.setCourXuefen(Integer.parseInt(xuefen));
AddCourseAction addCourse = new AddCourseAction();
String str = addCourse.addCourse(course);
if (str.equals("sucess")) {
JOptionPane.showMessageDialog(this, "添加課程成功!", "溫心提示",
JOptionPane.
INFORMATION_MESSAGE);
} else if (str.equals("failer")) {
JOptionPane.showMessageDialog(this, "添加課程失?。?!", "溫心提示",
JOptionPane.
INFORMATION_MESSAGE);
}
}
}
class addCourseFrame_btnSubmit_actionAdapter implements ActionListener {
private addCourseFrame adaptee;
addCourseFrame_btnSubmit_actionAdapter(addCourseFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnSubmit_actionPerformed(e);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -