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

📄 jproductfinder.java

📁 是一个专门设计用于触摸屏的POS(point of sales)应用软件
💻 JAVA
字号:
//    Tina POS is a point of sales application designed for touch screens.//    Copyright (C) 2005 Adrian Romero Corchado.//    http://sourceforge.net/projects/tinapos////    This program is free software; you can redistribute it and/or modify//    it under the terms of the GNU General Public License as published by//    the Free Software Foundation; either version 2 of the License, or//    (at your option) any later version.////    This program is distributed in the hope that it will be useful,//    but WITHOUT ANY WARRANTY; without even the implied warranty of//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//    GNU General Public License for more details.////    You should have received a copy of the GNU General Public License//    along with this program; if not, write to the Free Software//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USApackage net.adrianromero.tpv.panels;import javax.swing.*;import java.awt.*;import net.adrianromero.tpv.ticket.*;import net.adrianromero.tpv.forms.AppView;import net.adrianromero.tpv.forms.AppLocal;import net.adrianromero.basic.BasicException;import net.adrianromero.data.user.ListProvider;import net.adrianromero.data.user.ListProviderCreator;import net.adrianromero.tpv.forms.SentenceContainer;public class JProductFinder extends javax.swing.JDialog {    private ProductInfoExt m_ReturnProduct;    private ListProvider lpr;        /** Creates new form JProductFinder */    private JProductFinder(java.awt.Frame parent, boolean modal) {        super(parent, modal);    }    /** Creates new form JProductFinder */    private JProductFinder(java.awt.Dialog parent, boolean modal) {        super(parent, modal);    }            private ProductInfoExt init(AppView app) {                initComponents();                jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(35, 35));        //ProductFilter jproductfilter = new ProductFilter(app);        ProductFilterSales jproductfilter = new ProductFilterSales(app);        jproductfilter.activate();        m_jProductSelect.add(jproductfilter, BorderLayout.CENTER);                lpr = new ListProviderCreator(app.lookupDataLogic(SentenceContainer.class).getProductList(), jproductfilter);                  jListProducts.setCellRenderer(new ProductRenderer());                getRootPane().setDefaultButton(jcmdOK);              m_ReturnProduct = null;                //show();        setVisible(true);                return m_ReturnProduct;    }            private static Window getWindow(Component parent) {        if (parent == null) {            return new JFrame();        } else if (parent instanceof Frame || parent instanceof Dialog) {            return (Window)parent;        } else {            return getWindow(parent.getParent());        }    }            public static ProductInfoExt showMessage(Component parent, AppView app) {                 Window window = getWindow(parent);                JProductFinder myMsg;        if (window instanceof Frame) {             myMsg = new JProductFinder((Frame) window, true);        } else {            myMsg = new JProductFinder((Dialog) window, true);        }        return myMsg.init(app);    }            private static class MyListData extends javax.swing.AbstractListModel {                private java.util.List m_data;                public MyListData(java.util.List data) {            m_data = data;        }                public Object getElementAt(int index) {            return m_data.get(index);        }                public int getSize() {            return m_data.size();        }     }       /** 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();        jcmdOK = new javax.swing.JButton();        jcmdCancel = new javax.swing.JButton();        jPanel2 = new javax.swing.JPanel();        m_jProductSelect = new javax.swing.JPanel();        jPanel3 = new javax.swing.JPanel();        jButton3 = new javax.swing.JButton();        jScrollPane1 = new javax.swing.JScrollPane();        jListProducts = new javax.swing.JList();        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);        setTitle(AppLocal.getIntString("form.productslist"));        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));        jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/adrianromero/images/button_ok.png")));        jcmdOK.setText(AppLocal.getIntString("Button.OK"));        jcmdOK.setEnabled(false);        jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16));        jcmdOK.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jcmdOKActionPerformed(evt);            }        });        jPanel1.add(jcmdOK);        jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/adrianromero/images/button_cancel.png")));        jcmdCancel.setText(AppLocal.getIntString("Button.Cancel"));        jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16));        jcmdCancel.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jcmdCancelActionPerformed(evt);            }        });        jPanel1.add(jcmdCancel);        getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);        jPanel2.setLayout(new java.awt.BorderLayout());        jPanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));        m_jProductSelect.setLayout(new java.awt.BorderLayout());        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/adrianromero/images/launch.png")));        jButton3.setText(AppLocal.getIntString("button.executefilter"));        jButton3.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton3ActionPerformed(evt);            }        });        jPanel3.add(jButton3);        m_jProductSelect.add(jPanel3, java.awt.BorderLayout.SOUTH);        jPanel2.add(m_jProductSelect, java.awt.BorderLayout.NORTH);        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);        jListProducts.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);        jListProducts.addListSelectionListener(new javax.swing.event.ListSelectionListener() {            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {                jListProductsValueChanged(evt);            }        });        jListProducts.addMouseListener(new java.awt.event.MouseAdapter() {            public void mouseClicked(java.awt.event.MouseEvent evt) {                jListProductsMouseClicked(evt);            }        });        jScrollPane1.setViewportView(jListProducts);        jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();        setBounds((screenSize.width-665)/2, (screenSize.height-565)/2, 665, 565);    }// </editor-fold>//GEN-END:initComponents    private void jListProductsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListProductsMouseClicked        // TODO add your handling code here:        if (evt.getClickCount() == 2) {            m_ReturnProduct = (ProductInfoExt) jListProducts.getSelectedValue();            dispose();        }            }//GEN-LAST:event_jListProductsMouseClicked    private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed                // TODO add your handling code here:        m_ReturnProduct = (ProductInfoExt) jListProducts.getSelectedValue();        dispose();            }//GEN-LAST:event_jcmdOKActionPerformed    private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed                // TODO add your handling code here:        dispose();            }//GEN-LAST:event_jcmdCancelActionPerformed    private void jListProductsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListProductsValueChanged        // TODO add your handling code here:        jcmdOK.setEnabled(jListProducts.getSelectedValue() != null);            }//GEN-LAST:event_jListProductsValueChanged    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed        // TODO add your handling code here:        try {            jListProducts.setModel(new MyListData(lpr.loadData()));        } catch (BasicException e) {            e.printStackTrace();        }            }//GEN-LAST:event_jButton3ActionPerformed            // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton jButton3;    private javax.swing.JList jListProducts;    private javax.swing.JPanel jPanel1;    private javax.swing.JPanel jPanel2;    private javax.swing.JPanel jPanel3;    private javax.swing.JScrollPane jScrollPane1;    private javax.swing.JButton jcmdCancel;    private javax.swing.JButton jcmdOK;    private javax.swing.JPanel m_jProductSelect;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

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