?? dialog_student_search.java~12~
字號:
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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -