[java]代码库
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import school.schoolPicture.JdbcUtil;
public class StudentChooseCourse extends JFrame implements ActionListener {
JTextField jtfSearch = new JTextField(11);
String[] columnNames = new String[] { "课程ID", "课程名", "学时", "学分", "学期", "性质" };
DefaultTableModel dtmSearch = new DefaultTableModel(columnNames, 27);
JTable jtSearch = new JTable(dtmSearch);
JScrollPane jspSearch = new JScrollPane(jtSearch);
JComboBox jcbSearch = new JComboBox();
JTextField jtfSelectedCourse = new JTextField(10);
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
private static String usrName;
private static String passwrd;
//在构造方法中添加两个参数。以便在"提交"时,将学生的身份连同所选的课程,一同记录在学生选课表中。
public StudentChooseCourse(String usrName, String passwrd) {
createSearchCourse();
this.usrName = usrName;
this.passwrd = passwrd;
}
public String getUsrName() {
return usrName;
}
public void setUsrName(String usrName) {
this.usrName = usrName;
}
public String getPasswrd() {
return passwrd;
}
public void setPasswrd(String passwrd) {
this.passwrd = passwrd;
}