POS - Picture Frame In Sale Panel
Code snippetName: POS - A picture frame in sale panel
|
This functionality could be helpul in a grocery store (for example) to have a visual control of the currently scanned product.
This code is based on this forum thread.
- Create a com.openbravo.data.gui.JImageViewer class (refactor copy) based on the JImageEditor class.
- Remove the delete and open buttons in JImageViewer (not necessary here).
- In JPanelTicket.java create a JPanel and configure it with a border layout and deselect Horizontal/Vertical Resizable in Properties -> Layout.
- Add the beans object: com.openbravo.data.gui.JImageViewer to this new panel.
- Switch to a free design layout for the m_jPanContainer and place your new JPanel at your convenience.
- In the Inspector view of the design mode go to the root "Form ..." and right button -> Properties. Make sure Layout Generation Style is Standard Java 6 Code.
Code in JPanelTicket.java:
7. Import filesimport java.util.logging.Level; import java.util.logging.Logger; import javax.swing.event.ListSelectionListener; import javax.swing.event.ListSelectionEvent;8. Add the following lines
m_ticketlines.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int i = m_ticketlines.getSelectedIndex(); if (i >= 0) { try { String sProduct = m_oTicket.getLine(i).getProductID(); if (sProduct != null) { ProductInfoExt prod = JPanelTicket.this.dlSales.getProductInfo(sProduct); if (prod.getImage() != null) { m_jImage.setImage(prod.getImage()); } else { m_jImage.setImage(null); } } } catch (BasicException ex) { Logger.getLogger(JPanelTicket.class.getName()).log(Level.SEVERE, null, ex); } } } } });inside public void init(AppView app) after this line
m_jPanelCentral.add(m_ticketlines, java.awt.BorderLayout.CENTER);(thanks to Ilhami Kilic).