?? studenttextpanel.java~45~
字號:
package superframe.factionpanels.textpanel;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Color;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import superframe.link.SQLRunner;
public class StudentTextPanel extends TextPanel {
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel_name = new JLabel();
JLabel jLabel_nation = new JLabel();
JLabel jLabel_source = new JLabel();
JLabel jLabel_home_phone = new JLabel();
JLabel jLabel_stu_no = new JLabel();
JLabel jLabel_birthday = new JLabel();
JLabel jLabel_score = new JLabel();
JLabel jLabel_address = new JLabel();
JLabel jLabel_sex = new JLabel();
JLabel jLabel_polity = new JLabel();
JLabel jLabel_college = new JLabel();
JLabel jLabel13 = new JLabel();
JLabel jLabel14 = new JLabel();
JLabel jLabel11 = new JLabel();
JLabel jLabel15 = new JLabel();
JTextField jTextField_name = new JTextField();
JTextField jTextField_stu_no = new JTextField();
JComboBox jComboBox_sex = new JComboBox();
JComboBox jComboBox_nation = new JComboBox();
JFormattedTextField jFormattedTextField_birthday = new JFormattedTextField();
JComboBox jComboBox_polity = new JComboBox();
JTextField jTextField_score = new JTextField();
JTextField jTextField_home_phone = new JTextField();
JComboBox jComboBox_source = new JComboBox();
JTextField jTextField_address = new JTextField();
JComboBox jComboBox_college = new JComboBox();
JComboBox jComboBox_department = new JComboBox();
JComboBox jComboBox_class = new JComboBox();
JComboBox jComboBox_Build_no = new JComboBox();
JComboBox jComboBox_apartment_no = new JComboBox();
public StudentTextPanel(boolean e){
this.initialize(e);
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setLayout(xYLayout1);
jLabel_name.setText("姓名");
jLabel_nation.setText("民族");
jLabel_source.setText("學生來源");
jLabel_home_phone.setText("家庭聯系電話");
jLabel_stu_no.setText("學號");
jLabel_birthday.setText("出生日期");
jLabel_score.setText("入學成績");
jLabel_address.setText("家庭住址");
jLabel_sex.setText("性別");
jLabel_polity.setText("政治面貌");
jLabel_college.setText("學院");
jLabel13.setText("系");
jLabel14.setText("班");
jLabel11.setText("號樓");
jLabel15.setText("宿舍");
jTextField_name.setText("");
jTextField_stu_no.setText("");
jFormattedTextField_birthday.setFormatterFactory(null);
jFormattedTextField_birthday.setEnabled(true);
jFormattedTextField_birthday.setText("");
jTextField_score.setText("");
jTextField_home_phone.setText("");
jTextField_address.setText("");
jComboBox_sex.setEnabled(enable);
jTextField_home_phone.setEnabled(enable);
jTextField_home_phone.setDisabledTextColor(Color.black);
jComboBox_source.setEnabled(enable);
jComboBox_polity.setEnabled(enable);
jComboBox_nation.setEnabled(enable);
jTextField_name.setEnabled(enable);
jTextField_name.setDisabledTextColor(Color.black);
jTextField_stu_no.setEnabled(enable);
jTextField_stu_no.setDisabledTextColor(Color.black);
jFormattedTextField_birthday.setEnabled(enable);
jFormattedTextField_birthday.setDisabledTextColor(Color.black);
jTextField_score.setEnabled(enable);
jTextField_score.setDisabledTextColor(Color.black);
jTextField_address.setEnabled(enable);
jTextField_address.setDisabledTextColor(Color.black);
jComboBox_class.setEnabled(enable);
jComboBox_department.setEnabled(enable);
jComboBox_department.addActionListener(new
StudentTextPanel_jComboBox_department_actionAdapter(this));
jComboBox_Build_no.setEnabled(enable);
jComboBox_Build_no.addActionListener(new
StudentTextPanel_jComboBox_Build_no_actionAdapter(this));
jComboBox_apartment_no.setEnabled(enable);
jComboBox_college.setEnabled(enable);
jComboBox_college.addActionListener(new
StudentTextPanel_jComboBox_college_actionAdapter(this));
xYLayout1.setWidth(670);
xYLayout1.setHeight(420);
this.add(jLabel_birthday, new XYConstraints(38, 102, 97, 42));
this.add(jLabel_score, new XYConstraints(448, 106, 98, 35));
this.add(jLabel_address, new XYConstraints(38, 240, 97, 35));
this.add(jLabel_stu_no, new XYConstraints(183, 38, 36, 38));
this.add(jLabel_name, new XYConstraints(38, 38, 37, 39));
this.add(jLabel_nation, new XYConstraints(505, 40, 46, 36));
this.add(jLabel_source, new XYConstraints(38, 171, 73, 42));
this.add(jLabel_home_phone, new XYConstraints(259, 175, -1, 35));
this.add(jLabel_polity, new XYConstraints(253, 101, 58, 42));
this.add(jTextField_home_phone, new XYConstraints(354, 175, 185, 33));
this.add(jComboBox_source, new XYConstraints(128, 177, 102, 30));
this.add(jComboBox_polity, new XYConstraints(318, 105, 94, 31));
this.add(jComboBox_nation, new XYConstraints(552, 40, 100, 30));
this.add(jTextField_name, new XYConstraints(85, 39, 76, 31));
this.add(jTextField_stu_no, new XYConstraints(218, 40, 94, 30));
this.add(jFormattedTextField_birthday, new XYConstraints(104, 107, 140, 32));
this.add(jTextField_score, new XYConstraints(530, 107, 89, 29));
this.add(jTextField_address, new XYConstraints(113, 242, 532, 32));
this.add(jLabel13, new XYConstraints(573, 302, 92, 36));
this.add(jLabel_college, new XYConstraints(274, 302, 103, 36));
this.add(jComboBox_class, new XYConstraints(23, 358, 224, 30));
this.add(jLabel14, new XYConstraints(276, 353, 89, 36));
this.add(jLabel11, new XYConstraints(423, 358, 86, 33));
this.add(jLabel15, new XYConstraints(579, 354, 86, 41));
this.add(jComboBox_college, new XYConstraints(24, 302, 238, 32));
this.add(jComboBox_department, new XYConstraints(386, 304, 175, 31));
this.add(jComboBox_Build_no, new XYConstraints(355, 358, 65, 32));
this.add(jComboBox_apartment_no, new XYConstraints(474, 358, 99, 32));
this.add(jComboBox_sex, new XYConstraints(395, 40, 59, 29));
this.add(jLabel_sex, new XYConstraints(345, 35, 51, 36));
}
public void setAllInfo(String limit){
try {
boolean d=false;
resultSet=SQLRunner.getResult("select * from student where stu_no='"+keyValue+"'");
if(!resultSet.next())return;
if(!(resultSet.getString("dorm_no")==null)){
resultSet=SQLRunner.getResult("select * from studentinfo where Stu_no='"+keyValue+"'");
if(!resultSet.next())return;
d=true;
}
//if(!resultSet.next())return;
addItemFromDic(jComboBox_sex,"sex");
addItemFromDic(jComboBox_source,"source");
addItemFromDic(jComboBox_polity,"polity");
addItemFromDic(jComboBox_nation,"nation");
selectItemAsResult(jComboBox_nation,"nation");
selectItemAsResult(jComboBox_polity,"polity");
selectItemAsResult(jComboBox_source,"source");
selectItemAsResult(jComboBox_sex,"sex");
jTextField_home_phone.setText(resultSet.getString("home_phone"));
jTextField_stu_no.setText(resultSet.getString("stu_no"));
jTextField_name.setText(resultSet.getString("sname"));
jFormattedTextField_birthday.setText(resultSet.getString("birthday"));
jTextField_score.setText(resultSet.getString("score"));
jTextField_address.setText(resultSet.getString("address"));
resultSet=SQLRunner.getResult("select * from studentinfo where class_no='"+limit+"'");
if(!resultSet.next())return;
//resultSet=SQLRunner.getResult("select * from studentinfo where class_no='"+limit+"'");
//addItem(jComboBox_college,"select * from college","coname");
//jComboBox_college.
jComboBox_college.addItem(resultSet.getString("coname"));
jComboBox_college.setSelectedItem(resultSet.getString("coname"));
//jComboBox_college.setEnabled(false);
//addItemFromDpt(jComboBox_department,jComboBox_college);
jComboBox_department.addItem(resultSet.getString("dpname"));
jComboBox_department.setSelectedItem(resultSet.getString("dpname"));
//jComboBox_department.setEnabled(false);
//addItemFromCls(jComboBox_class,jComboBox_department);
jComboBox_class.addItem(resultSet.getString("clname"));
jComboBox_class.setSelectedItem(resultSet.getString("clname"));
//jComboBox_class.setEnabled(false);
addItemFromBld(jComboBox_Build_no);
if(d){
jComboBox_Build_no.setSelectedItem(resultSet.getString("Build_no"));
addItemFromRom(jComboBox_apartment_no,jComboBox_Build_no);
jComboBox_apartment_no.setSelectedItem(resultSet.getString("apartment_no"));
}else{
jComboBox_Build_no.setSelectedItem(null);
addItemFromRom(jComboBox_apartment_no,jComboBox_Build_no);
jComboBox_apartment_no.setSelectedItem(null);
}
} catch (SQLException ex) {
System.out.print(ex.toString());
}
}
void addItemFromDpt(JComboBox jcb,JComboBox p) throws SQLException {
jcb.removeAllItems();
String colname=new String();
if(p.getItemCount()==0){
return;
}else{
if(p.getSelectedItem()==null)return;
colname=((String)p.getSelectedItem());
ResultSet rdepartment=SQLRunner.getResult("select * from department,college where department.college_no=college.college_no and coname='"+colname+"'");
while(rdepartment.next()){jcb.addItem(rdepartment.getString("dpname"));}
}
}
void addItemFromCls(JComboBox jcb,JComboBox p) throws SQLException {
jcb.removeAllItems();
String dptname=new String();
if(p.getItemCount()==0){
return;
}else{
if(p.getSelectedItem()==null)return;
dptname=((String)p.getSelectedItem());
ResultSet rdepartment=SQLRunner.getResult("select * from department,class where department.depart_no=class.depart_no and dpname='"+dptname+"'");
while(rdepartment.next()){jcb.addItem(rdepartment.getString("clname"));}
}
}
void addItemFromBld(JComboBox jcb) throws SQLException {
jcb.removeAllItems();
ResultSet rbuilding=SQLRunner.getResult("select * from DORMITORY");
while(rbuilding.next()){jcb.addItem(rbuilding.getString("BUILD_NO"));}
}
void addItemFromRom(JComboBox jcb,JComboBox p) throws SQLException {
jcb.removeAllItems();
String bno=new String();
if(p.getItemCount()==0){
return;
}else{
if(p.getSelectedItem()==null)return;
bno=((String)p.getSelectedItem()).trim();
ResultSet rroom=SQLRunner.getResult("select * from DORMITORY where build_no='"+bno+"'");
while(rroom.next()){jcb.addItem(rroom.getString("apartment_no"));}
}
}
public void setAllNull() {
jComboBox_nation.setSelectedItem(null);
jComboBox_sex.setSelectedItem(null);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -