📄 findabook.java
字号:
/* * findAbook.java * * Created on 2007年12月23日, 下午12:58 */package com.sxy.frame;import com.sxy.database.DabaCon;/** * * @author Arthur */public class findAbook extends javax.swing.JFrame { /** Creates new form findAbook */ public findAbook(String uname) { this.uname = uname; initComponents(); } /** 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); username = new javax.swing.JTextField(); findbyname = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); phone = new javax.swing.JTextField(); findbyphone = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setTitle("查找"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { windowclsing(evt); } }); getContentPane().setLayout(new java.awt.FlowLayout()); jLabel1.setText("按用户名查找:"); jPanel1.add(jLabel1); username.setColumns(15); username.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { usernameKeyPressed(evt); } }); jPanel1.add(username); findbyname.setText("查找"); findbyname.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { findbynameActionPerformed(evt); } }); jPanel1.add(findbyname); getContentPane().add(jPanel1); jLabel2.setText("按手机号查找:"); jPanel2.add(jLabel2); phone.setColumns(15); phone.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { phoneKeyPressed(evt); } }); jPanel2.add(phone); findbyphone.setText("查找"); findbyphone.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { findbyphoneActionPerformed(evt); } }); jPanel2.add(findbyphone); getContentPane().add(jPanel2); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width-408)/2, (screenSize.height-160)/2, 408, 160); }// </editor-fold>//GEN-END:initComponents private void findbynameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_findbynameActionPerformed DabaCon con = new DabaCon(); con.condata(); String name = username.getText(); new AddBookMain(con.selectbyname(name, uname), uname).setVisible(true); con.close(); this.dispose(); // TODO add your handling code here: }//GEN-LAST:event_findbynameActionPerformed private void findbyphoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_findbyphoneActionPerformed DabaCon con = new DabaCon(); con.condata(); String name = phone.getText(); new AddBookMain(con.selectbyphone(name, uname), uname).setVisible(true); con.close(); this.dispose(); // TODO add your handling code here:}//GEN-LAST:event_findbyphoneActionPerformed private void windowclsing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_windowclsing new AddBookMain(uname).setVisible(true); // TODO add your handling code here: }//GEN-LAST:event_windowclsing private void usernameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_usernameKeyPressed if(evt.getKeyCode()==java.awt.event.KeyEvent.VK_ENTER){ findbyname.grabFocus(); } // TODO add your handling code here: }//GEN-LAST:event_usernameKeyPressed private void phoneKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_phoneKeyPressed if(evt.getKeyCode()==java.awt.event.KeyEvent.VK_ENTER){ findbyphone.grabFocus(); } // TODO add your handling code here: }//GEN-LAST:event_phoneKeyPressed /** * @param args the command line arguments */ /* public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new findAbook(uname).setVisible(true); } }); }*/ public static String uname; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton findbyname; private javax.swing.JButton findbyphone; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JTextField phone; private javax.swing.JTextField username; // End of variables declaration//GEN-END:variables}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -