⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmlibsearch.java~27~

📁 用java实现的一个应用程序,源码非常完整,可以直接运行
💻 JAVA~27~
📖 第 1 页 / 共 2 页
字号:
        pnlLibMessage.add(lblPage);
        pnlLibMessage.add(lblSearchPublish);
        pnlLibMessage.add(lblSort);
        pnlLibMessage.add(txtSort);
        pnlLibMessage.add(txtIsin);
        pnlLibMessage.add(lblIsin);
        pnlLibMessage.add(txtSynopsis);
        pnlLibMessage.add(btnSearch);
        pnlLibMessage.add(btnCancel);
        pnlLibMessage.add(btnExit);
        pnlLibMessage.add(rbnBlurrySearch);
        pnlLibMessage.add(rbnExactSearch);
        pnlLibMessage.add(lblLine);
        pnlLibMessage.add(lblSynopsis);
        pnlLibMessage.add(txtLoanCount);
        pnlLibMessage.add(lblBorrowCount);
        pnlLibMessage.add(lblLocation);
        this.getContentPane().add(pnlLibMessage);
        this.getContentPane().add(lblDisplay);
        this.getContentPane().add(jScrollPane1);
        jScrollPane1.getViewport().add(tblDisplay);
        buttonGroup1.add(rbnExactSearch);
        buttonGroup1.add(rbnBlurrySearch);
        rbnExactSearch.setSelected(true);
        this.setTitle("图书查询");
        DisplayAllBook();
        tblDisplay.setAutoResizeMode(tblDisplay.AUTO_RESIZE_OFF);
        tblDisplay.getTableHeader().setReorderingAllowed(false);
    }

    public void Displaynull()
    {
        Vector vt = new Vector();
        dt = new DefaultTableModel(vt,vtColName);
        tblDisplay.setModel(dt);
        txtId.setText("");
        txtBarCode.setText("");
        txtName.setText("");
        txtAuthor.setText("");
        txtPage.setText("");
        txtPublish.setText("");
        txtIsbn.setText("");
        txtPrice.setText("");
        txtSort.setText("");
        txtIntoTime.setText("");
        txtLocation.setText("");
        txtIsin.setText("");
        txtLoanCount.setText("");
        txtSynopsis.setText("");
    }

    public void DisplayAllBook()
    {
        for (int i = 0; i < column.length; i++) {
            vtColName.add(column[i]);
        }
        BookConDB bookDB = new BookConDB();
        vt = bookDB.SearchAll();
        bookDB.CloseBookDB();
        dt = new DefaultTableModel(vt, vtColName);
        tblDisplay.setModel(dt);
        txtId.setText(String.valueOf(tblDisplay.getValueAt(0,0)));
        txtBarCode.setText(String.valueOf(tblDisplay.getValueAt(0,1)));
        txtName.setText(String.valueOf(tblDisplay.getValueAt(0,2)));
        txtAuthor.setText(String.valueOf(tblDisplay.getValueAt(0,3)));
        txtPage.setText(String.valueOf(tblDisplay.getValueAt(0,4)));
        txtPublish.setText(String.valueOf(tblDisplay.getValueAt(0,5)));
        txtIsbn.setText(String.valueOf(tblDisplay.getValueAt(0,6)));
        txtPrice.setText(String.valueOf(tblDisplay.getValueAt(0,7)));
        txtSort.setText(String.valueOf(tblDisplay.getValueAt(0,8)));
        txtIntoTime.setText(String.valueOf(tblDisplay.getValueAt(0,9)));
        txtLocation.setText(String.valueOf(tblDisplay.getValueAt(0,10)));
        txtIsin.setText(String.valueOf(tblDisplay.getValueAt(0,11)));
        txtLoanCount.setText(String.valueOf(tblDisplay.getValueAt(0,12)));
        txtSynopsis.setText(String.valueOf(tblDisplay.getValueAt(0,13)));
    }

    public void ShowLibSearch()
    {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension dlgSize = this.getSize();
        if (dlgSize.height > screenSize.height) {
            dlgSize.height = screenSize.height;
         }
        if (dlgSize.width > screenSize.width) {
            dlgSize.width = screenSize.width;
         }
        this.setLocation((screenSize.width - dlgSize.width) / 2,
                         (screenSize.height - dlgSize.height) / 2);
        this.setVisible(true);
    }


    public void this_componentResized(ComponentEvent e) {
 //       tblDisplay.setSize(this.getWidth()-35,this.getHeight()-35);
        pnlLibMessage.setLocation((this.getWidth() - pnlLibMessage.getWidth())/2,0);
        jScrollPane1.setSize(this.getWidth()-30,this.getHeight()-pnlLibMessage.getHeight()-65);
        tblDisplay.setSize(jScrollPane1.getWidth(),jScrollPane1.getHeight());
 //       jScrollPane1.setLocation((this.getWidth() - jScrollPane1.getWidth())/2,0);
//        tblDisplay.setSize(jScrollPane1.getWidth(),jScrollPane1.getHeight());
    }

    public void btnSearch_actionPerformed(ActionEvent e) {
        String Id = txtSearchId.getText();
        String BarCode = txtSearchBarCode.getText();
        String Name = txtSearchName.getText();
        String Author = txtSearchAuthor.getText();
        String Publish = txtSearchPublish.getText();
        String Sort = txtSearchSort.getText();
        BookConDB bookDB = new BookConDB();
        boolean Isnot;
        if (rbnExactSearch.isSelected()) {
            Isnot = true;
        } else {
            for (int i = 0; i < Id.length(); i++) {
                if (String.valueOf(Id.charAt(i)).equals("%")) {
                    JOptionPane.showMessageDialog(null, "模糊查询不能含有特殊符号\"%\"!");
                    return;
                }
            }
            for (int i = 0; i < BarCode.length(); i++) {
                if (String.valueOf(BarCode.charAt(i)).equals("%")) {
                    JOptionPane.showMessageDialog(null, "模糊查询不能含有特殊符号\"%\"!");
                    return;
                }
            }
            for (int i = 0; i < Author.length(); i++) {
                if (String.valueOf(Author.charAt(i)).equals("%")) {
                    JOptionPane.showMessageDialog(null, "模糊查询不能含有特殊符号\"%\"!");
                    return;
                }
            }
            for (int i = 0; i < Author.length(); i++) {
                if (String.valueOf(Author.charAt(i)).equals("%")) {
                    JOptionPane.showMessageDialog(null, "模糊查询不能含有特殊符号\"%\"!");
                    return;
                }
            }
            for (int i = 0; i < Publish.length(); i++) {
                if (String.valueOf(Publish.charAt(i)).equals("%")) {
                    JOptionPane.showMessageDialog(null, "模糊查询不能含有特殊符号\"%\"!");
                    return;
                }
            }
            for (int i = 0; i < Sort.length(); i++) {
                if (String.valueOf(Sort.charAt(i)).equals("%")) {
                    JOptionPane.showMessageDialog(null, "模糊查询不能含有特殊符号\"%\"!");
                    return;
                }
            }
            Isnot = false;
        }
        if (Id.equals("") && BarCode.equals("") && Name.equals("") &&
            Author.equals("") && Publish.equals("") && Sort.equals("")) {
            Displaynull();
            JOptionPane.showMessageDialog(this, "请输入内容");
        } else {
            vt = bookDB.SearchBook(Id, BarCode, Name, Author, Publish, Sort, Isnot);
            bookDB.CloseBookDB();
            if (vt.size() < 1) {
                Displaynull();
                JOptionPane.showMessageDialog(this, "找不到记录!");
            } else {
                dt = new DefaultTableModel(vt, vtColName);
                tblDisplay.setModel(dt);
                int row = tblDisplay.getSelectedRow();
                if (row < 0) {
                    row++;
                }
                txtId.setText(String.valueOf(tblDisplay.getValueAt(row, 0)));
                txtBarCode.setText(String.valueOf(tblDisplay.getValueAt(row, 1)));
                txtName.setText(String.valueOf(tblDisplay.getValueAt(row, 2)));
                txtAuthor.setText(String.valueOf(tblDisplay.getValueAt(row, 3)));
                txtPage.setText(String.valueOf(tblDisplay.getValueAt(row, 4)));
                txtPublish.setText(String.valueOf(tblDisplay.getValueAt(row, 5)));
                txtIsbn.setText(String.valueOf(tblDisplay.getValueAt(row, 6)));
                txtPrice.setText(String.valueOf(tblDisplay.getValueAt(row, 7)));
                txtSort.setText(String.valueOf(tblDisplay.getValueAt(row, 8)));
                txtIntoTime.setText(String.valueOf(tblDisplay.getValueAt(row, 9)));
                txtLocation.setText(String.valueOf(tblDisplay.getValueAt(row, 10)));
                txtIsin.setText(String.valueOf(tblDisplay.getValueAt(row, 11)));
                txtLoanCount.setText(String.valueOf(tblDisplay.getValueAt(row, 12)));
                txtSynopsis.setText(String.valueOf(tblDisplay.getValueAt(row, 13)));
            }
        }
    }
    public void tblDisplay_mouseClicked(MouseEvent e) {
        int row = tblDisplay.getSelectedRow();
        txtId.setText(String.valueOf(tblDisplay.getValueAt(row,0)));
        txtBarCode.setText(String.valueOf(tblDisplay.getValueAt(row,1)));
        txtName.setText(String.valueOf(tblDisplay.getValueAt(row,2)));
        txtAuthor.setText(String.valueOf(tblDisplay.getValueAt(row,3)));
        txtPage.setText(String.valueOf(tblDisplay.getValueAt(row,4)));
        txtPublish.setText(String.valueOf(tblDisplay.getValueAt(row,5)));
        txtIsbn.setText(String.valueOf(tblDisplay.getValueAt(row,6)));
        txtPrice.setText(String.valueOf(tblDisplay.getValueAt(row,7)));
        txtSort.setText(String.valueOf(tblDisplay.getValueAt(row,8)));
        txtIntoTime.setText(String.valueOf(tblDisplay.getValueAt(row,9)));
        txtLocation.setText(String.valueOf(tblDisplay.getValueAt(row,10)));
        txtIsin.setText(String.valueOf(tblDisplay.getValueAt(row,11)));
        txtLoanCount.setText(String.valueOf(tblDisplay.getValueAt(row,12)));
        txtSynopsis.setText(String.valueOf(tblDisplay.getValueAt(row,13)));
    }

    public void btnCancel_actionPerformed(ActionEvent e) {
        txtSearchId.setText("");
        txtSearchBarCode.setText("");
        txtSearchName.setText("");
        txtSearchAuthor.setText("");
        txtSearchPublish.setText("");
        txtSearchSort.setText("");
    }

    public void btnExit_actionPerformed(ActionEvent e) {
        this.dispose();
    }
}


class frmLibSearch_btnExit_actionAdapter implements ActionListener {
    private frmLibSearch adaptee;
    frmLibSearch_btnExit_actionAdapter(frmLibSearch adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnExit_actionPerformed(e);
    }
}


class frmLibSearch_btnCancel_actionAdapter implements ActionListener {
    private frmLibSearch adaptee;
    frmLibSearch_btnCancel_actionAdapter(frmLibSearch adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnCancel_actionPerformed(e);
    }
}


class frmLibSearch_tblDisplay_mouseAdapter extends MouseAdapter {
    private frmLibSearch adaptee;
    frmLibSearch_tblDisplay_mouseAdapter(frmLibSearch adaptee) {
        this.adaptee = adaptee;
    }

    public void mouseClicked(MouseEvent e) {
        adaptee.tblDisplay_mouseClicked(e);
    }
}


class frmLibSearch_btnSearch_actionAdapter implements ActionListener {
    private frmLibSearch adaptee;
    frmLibSearch_btnSearch_actionAdapter(frmLibSearch adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnSearch_actionPerformed(e);
    }
}


class frmLibSearch_this_componentAdapter extends ComponentAdapter {
    private frmLibSearch adaptee;
    frmLibSearch_this_componentAdapter(frmLibSearch adaptee) {
        this.adaptee = adaptee;
    }

    public void componentResized(ComponentEvent e) {
        adaptee.this_componentResized(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -