Professional Documents
Culture Documents
DefaultTableModel;
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
/** * 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 Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() {
jLabel4 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); pdtn = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}, new String [] { "Customer ID", "Customer Name", "Address", "Phone Number" } )); jScrollPane1.setViewportView(jTable1);
jLabel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(layout.createSequentialGroup()
.addGap(283, 283, 283) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(100, 100, 100) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(layout.createSequentialGroup() .addGap(80, 80, 80) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20) .addComponent(pdtn, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(23, 23, 23) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(9, 9, 9) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 680, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGap(97, 97, 97) .addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 688, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(98, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(11, 11, 11) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(14, 14, 14) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addComponent(jLabel3)) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addComponent(pdtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(24, 24, 24) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(37, Short.MAX_VALUE)) );
private void jLabel4MouseClicked(java.awt.event.MouseEvent evt) { this.setVisible(false); } // TODO add your handling code here:
private void pdtnActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
jTable1.getModel(); try { Class.forName("java.sql.DriverManager"); Connection con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/ p2p_library","root","tiger"); Statement stmt=(Statement) con.createStatement(); String query="SELECT CUSTOMER_ID,CUSTOMER_NAME,ADDRESS,PH_NO FROM cus1 where customer_id='"+m+"';";
ResultSet rs=stmt.executeQuery(query);
int columns = rs.getMetaData().getColumnCount(); while (rs.next()) { Object[] row = new Object[columns]; for (int i = 1; i <= columns; i++) { row[i - 1] = rs.getObject(i); // 1 } ((DefaultTableModel) jTable1.getModel()).insertRow(rs.getRow() - 1, row); }
/**
* @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(search_customer.class.getName()).log(java .util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(search_customer.class.getName()).log(java .util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(search_customer.class.getName()).log(java
.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(search_customer.class.getName()).log(java .util.logging.Level.SEVERE, null, ex); } //</editor-fold>
/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new search_customer().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel7; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable1; private javax.swing.JTextField pdtn; // End of variables declaration }