?? zhufang2.java
字號:
/* * zhufang2.java * * Created on 2001年6月2日, 下午7:28 */package zc.face;import java.sql.*;import java.io.*;/** * * @author Administrator * @version */public class zhufang2 extends javax.swing.JFrame { /** Creates new form zhufang2 */ public zhufang2() { initComponents (); pack (); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ private void initComponents() {//GEN-BEGIN:initComponents jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jPanel3 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); setTitle("\u4f4f\u623f\u4fe1\u606f\u67e5\u8be2\u754c\u97622"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { exitForm(evt); } } ); jPanel1.setLayout(new java.awt.BorderLayout()); jLabel1.setText("\u8bf7\u8f93\u5165\u4e0b\u5217\u5185\u5bb9\u8fdb\u884c\u67e5\u8be2"); jPanel1.add(jLabel1, java.awt.BorderLayout.NORTH); jPanel2.setLayout(new java.awt.GridBagLayout()); java.awt.GridBagConstraints gridBagConstraints1; jLabel2.setText("\u95e8\u724c\u53f7:"); gridBagConstraints1 = new java.awt.GridBagConstraints(); jPanel2.add(jLabel2, gridBagConstraints1); jTextField1.setColumns(10); gridBagConstraints1 = new java.awt.GridBagConstraints(); jPanel2.add(jTextField1, gridBagConstraints1); jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER); getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); jButton1.setText("\u67e5\u8be2"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } } ); jPanel3.add(jButton1); jButton2.setText("\u7ee7\u7eed\u67e5\u8be2"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } } ); jPanel3.add(jButton2); jButton3.setText("\u53d6\u6d88"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } } ); jPanel3.add(jButton3); getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH); }//GEN-END:initComponents private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(ClassNotFoundException ce){ System.out.println("SQLException:"+ce.getMessage()); } try { if(!jTextField1.getText( ).equals(" ")) { Connection con=DriverManager.getConnection("jdbc:odbc:houqin"); System.out.println("鏈接成功"); System.out.println("sql查詢:"); String query="select * from zhufang"+ " where 門牌號='"+jTextField1.getText( )+"'"; System.out.println(query); //進行數據庫查詢 Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery(query); System.out.println(zc.face.MySqlUnit.printResultSet(rs)); //System.out.println("查詢成功"); stmt.close(); con.close(); } else System.out.println("請輸入正確的門牌號后按查詢按鈕"); } catch(SQLException e){ System.out.println("SQLException:"+e.getMessage()); } catch(IOException e2){ System.out.println("IOException:"+e2.getMessage()); } // Add your handling code here: }//GEN-LAST:event_jButton1ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed jTextField1.setText(" "); // Add your handling code here: }//GEN-LAST:event_jButton2ActionPerformed private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed zc.face.userInterface2 jf1=new zc.face.userInterface2(); jf1.setVisible(true); setVisible(false); // Add your handling code here: }//GEN-LAST:event_jButton3ActionPerformed /** Exit the Application */ private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm System.exit (0); }//GEN-LAST:event_exitForm /** * @param args the command line arguments */ public static void main (String args[]) { new zhufang2 ().show (); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel jPanel1; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel2; private javax.swing.JLabel jLabel2; private javax.swing.JTextField jTextField1; private javax.swing.JPanel jPanel3; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; // End of variables declaration//GEN-END:variables}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -