查找模块:
年龄可进行段查找。 其他的都是模糊匹配。 空格为无用字符,会屏蔽的(除年龄)。 (如果在年龄中输入空格,会出现异常,当时没想到这点,要防护这点很容易的,但因为在这个小软件的编写过程,我主要学的是java项目开发的分层思想,软件可能bug比较多,望见谅。)/* * QueryPanel.java * */package cn.hncu.addr.ui;import javax.swing.JFrame;import javax.swing.JOptionPane;import cn.hncu.addr.business.AddrBusiness;/** * * @author __chx__ */public class QueryPanel extends javax.swing.JPanel { private JFrame mainFrame = null; String[] strsQu = null; public QueryPanel(JFrame mainFrame) { this.mainFrame = mainFrame; initComponents(); myInitComponents(); } private void myInitComponents() { strsQu = new String[6]; jtfAge1.setText("0"); jtfAge.setText("999"); } private void initComponents() { jLabel2 = new javax.swing.JLabel(); jlbName1 = new javax.swing.JLabel(); jtfName = new javax.swing.JTextField(); jtfxingbie = new javax.swing.JTextField(); jlbxingbie = new javax.swing.JLabel(); jlbAge = new javax.swing.JLabel(); jtfAge = new javax.swing.JTextField(); jtfDianhua = new javax.swing.JTextField(); jlbDianhau = new javax.swing.JLabel(); jlbAddress = new javax.swing.JLabel(); jtfAddress = new javax.swing.JTextField(); jbtnFind = new javax.swing.JButton(); jbtnreturn = new javax.swing.JButton(); jtfAge1 = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); setMinimumSize(new java.awt.Dimension(800, 600)); setLayout(null); jLabel2.setFont(new java.awt.Font("Microsoft YaHei UI", 3, 48)); jLabel2.setForeground(new java.awt.Color(255, 51, 0)); jLabel2.setText("\u67e5\u627e\u5730\u5740\u4fe1\u606f"); add(jLabel2); jLabel2.setBounds(230, 20, 330, 90); jlbName1.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); jlbName1.setText("\u59d3\u540d\uff1a"); add(jlbName1); jlbName1.setBounds(140, 150, 60, 40); add(jtfName); jtfName.setBounds(200, 160, 130, 23); add(jtfxingbie); jtfxingbie.setBounds(200, 200, 190, 23); jlbxingbie.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); jlbxingbie.setText("\u6027\u522b\uff1a"); add(jlbxingbie); jlbxingbie.setBounds(140, 190, 60, 40); jlbAge.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); jlbAge.setText("\u5e74\u9f84\u6bb5\uff1a"); add(jlbAge); jlbAge.setBounds(120, 230, 80, 40); add(jtfAge); jtfAge.setBounds(340, 240, 70, 23); add(jtfDianhua); jtfDianhua.setBounds(200, 280, 330, 23); jlbDianhau.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); jlbDianhau.setText("\u7535\u8bdd\uff1a"); add(jlbDianhau); jlbDianhau.setBounds(140, 270, 60, 40); jlbAddress.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 18)); jlbAddress.setText("\u5730\u5740\uff1a"); add(jlbAddress); jlbAddress.setBounds(140, 310, 60, 40); add(jtfAddress); jtfAddress.setBounds(200, 320, 410, 23); jbtnFind.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 24)); jbtnFind.setForeground(new java.awt.Color(255, 0, 51)); jbtnFind.setText("\u67e5\u627e"); jbtnFind.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnFindActionPerformed(evt); } }); add(jbtnFind); jbtnFind.setBounds(140, 430, 110, 70); jbtnreturn.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 24)); jbtnreturn.setForeground(new java.awt.Color(0, 204, 204)); jbtnreturn.setText("\u53d6\u6d88"); jbtnreturn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnreturnActionPerformed(evt); } }); add(jbtnreturn); jbtnreturn.setBounds(490, 430, 110, 70); add(jtfAge1); jtfAge1.setBounds(200, 240, 70, 23); jLabel1.setText("\u2014\u2014"); add(jLabel1); jLabel1.setBounds(290, 240, 41, 17); } private void jbtnreturnActionPerformed(java.awt.event.ActionEvent evt) { mainFrame.setContentPane(new ListPanel(mainFrame)); mainFrame.validate(); } private void jbtnFindActionPerformed(java.awt.event.ActionEvent evt) { // 表现层代码的基本写法 strsQu[0] = jtfName.getText(); strsQu[1] = jtfxingbie.getText(); strsQu[2] = jtfAge1.getText(); strsQu[3] = jtfDianhua.getText(); strsQu[4] = jtfAddress.getText(); strsQu[5] = jtfAge.getText(); // 3.调用逻辑层 AddrBusiness set = new AddrBusiness(); Object[] objs = set.query(strsQu);// for(int i=0;i