View source | Discuss this page | Page history | Printable version   

POS - Picture Frame In Sale Panel

Code snippet

Name: POS - A picture frame in sale panel
Version: POS 2.30
Author: Henri Azar



This functionality could be helpul in a grocery store (for example) to have a visual control of the currently scanned product.

Sale panel with picture frame

This code is based on this forum thread.

  1. Create a com.openbravo.data.gui.JImageViewer class (refactor copy) based on the JImageEditor class.
  2. Remove the delete and open buttons in JImageViewer (not necessary here).
  3. In JPanelTicket.java create a JPanel and configure it with a border layout and deselect Horizontal/Vertical Resizable in Properties -> Layout.
  4. Add the beans object: com.openbravo.data.gui.JImageViewer to this new panel.
  5. Switch to a free design layout for the m_jPanContainer and place your new JPanel at your convenience.
  6. 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 files
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent; 
Sale panel with picture frame (<cat-height value="0" />, 800x600)
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).

Retrieved from "http://wiki.openbravo.com/wiki/POS_-_Picture_Frame_In_Sale_Panel"

This page has been accessed 12,687 times. This page was last modified on 25 November 2011, at 00:25. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.