dialog_student_search.java~12~

来自「学生上机系统,请大家多多指教.以后会发」· JAVA~12~ 代码 · 共 162 行

JAVA~12~
162
字号
package student_computer;import java.awt.*;import javax.swing.*;import com.borland.dx.sql.dataset.*;import com.borland.dbswing.*;import com.borland.dx.dataset.*;import java.awt.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class Dialog_student_search extends JDialog {  JPanel panel1 = new JPanel();  BorderLayout borderLayout1 = new BorderLayout();  FlowLayout flowLayout1 = new FlowLayout();  JLabel jLabel1 = new JLabel();  JTextField jTextField1 = new JTextField();  JButton jButton1 = new JButton();  JPanel jPanel1 = new JPanel();  BorderLayout borderLayout2 = new BorderLayout();  Database database1 = new Database();  QueryDataSet queryDataSet1 = new QueryDataSet();  JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();  TableScrollPane tableScrollPane1 = new TableScrollPane();  JdbTable jdbTable1 = new JdbTable();  JdbStatusLabel jdbStatusLabel1 = new JdbStatusLabel();  QueryDataSet queryDataSet2 = new QueryDataSet();  ParameterRow parameterRow1 = new ParameterRow();  Column column1 = new Column();  JButton jButton2 = new JButton();  JLabel jLabel2 = new JLabel();  JLabel jLabel3 = new JLabel();  JLabel jLabel4 = new JLabel();  JLabel jLabel5 = new JLabel();  JLabel jLabel6 = new JLabel();  public Dialog_student_search(Frame frame, String title, boolean modal) {    super(frame, title, modal);    try {      jbInit();      pack();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  public Dialog_student_search() {    this(null, "", false);  }  private void jbInit() throws Exception {    panel1.setLayout(flowLayout1);    this.getContentPane().setLayout(borderLayout1);    jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));    jLabel1.setText("学号:");    jButton1.setFont(new java.awt.Font("Dialog", 0, 12));    jButton1.setText("查询");    jButton1.addActionListener(new Dialog_student_search_jButton1_actionAdapter(this));    jPanel1.setLayout(borderLayout2);    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:microsoft:sqlserver://210.30.104.11:1433;DatabaseName=student_computer", "xueli", "gejingguo", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select * from student;", null, true, Load.ALL));    jdbStatusLabel1.setText("jdbStatusLabel1");    jdbTable1.setDataSet(queryDataSet1);    column1.setColumnName("student_num");    column1.setDataType(com.borland.dx.dataset.Variant.STRING);    column1.setPreferredOrdinal(0);    column1.setServerColumnName("NewColumn1");    column1.setSqlType(0);    parameterRow1.setColumns(new Column[] {column1});    queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "select * from student where student_number=:student_num;", parameterRow1, true, Load.ALL));    jButton2.setFont(new java.awt.Font("Dialog", 0, 12));    jButton2.setText("查看全部");    jButton2.addActionListener(new Dialog_student_search_jButton2_actionAdapter(this));    jLabel3.setText("           ");    jLabel4.setText("            ");    jLabel6.setText("      ");    jLabel5.setText("");    jLabel2.setText("         ");    jTextField1.setText("学号             ");    getContentPane().add(panel1,  BorderLayout.NORTH);    panel1.add(jLabel5, null);    panel1.add(jLabel1, null);    panel1.add(jTextField1, null);    panel1.add(jLabel2, null);    panel1.add(jButton1, null);    panel1.add(jLabel3, null);    panel1.add(jLabel4, null);    panel1.add(jLabel6, null);    panel1.add(jButton2, null);    this.getContentPane().add(jPanel1, BorderLayout.CENTER);    jPanel1.add(jdbNavToolBar1, BorderLayout.NORTH);    jPanel1.add(tableScrollPane1, BorderLayout.CENTER);    jPanel1.add(jdbStatusLabel1,  BorderLayout.SOUTH);    tableScrollPane1.getViewport().add(jdbTable1, null);    this.setTitle("学生信息查询");   // this.setSize(350,350);    //this.setLocation(210,200);    this.setVisible(true);  }////////////////////按学号查询学生  void jButton1_actionPerformed(ActionEvent e) {     String id=jTextField1.getText();     if(id.equals(""))     {       JOptionPane.showMessageDialog(this,"学号不能为空!!!","提示",JOptionPane.PLAIN_MESSAGE);       return;     }     parameterRow1.setString("student_num",id);     jdbTable1.setDataSet(queryDataSet2);     jdbNavToolBar1.setDataSet(queryDataSet2);     jdbStatusLabel1.setDataSet(queryDataSet2);     queryDataSet2.refresh();  }////////////返回全部学生信息  void jButton2_actionPerformed(ActionEvent e) {    DataSet da=jdbTable1.getDataSet();    if(da==queryDataSet1)    {      JOptionPane.showMessageDialog(this,"已经显示全部数据!!!","提示",JOptionPane.PLAIN_MESSAGE);      return;    }    else    {      jdbTable1.setDataSet(queryDataSet1);     jdbNavToolBar1.setDataSet(queryDataSet1);     jdbStatusLabel1.setDataSet(queryDataSet1);     queryDataSet2.refresh();    }  }}class Dialog_student_search_jButton1_actionAdapter implements java.awt.event.ActionListener {  Dialog_student_search adaptee;  Dialog_student_search_jButton1_actionAdapter(Dialog_student_search adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class Dialog_student_search_jButton2_actionAdapter implements java.awt.event.ActionListener {  Dialog_student_search adaptee;  Dialog_student_search_jButton2_actionAdapter(Dialog_student_search adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?