Example usage for javax.swing JMenuItem addMouseMotionListener

List of usage examples for javax.swing JMenuItem addMouseMotionListener

Introduction

In this page you can find the example usage for javax.swing JMenuItem addMouseMotionListener.

Prototype

public synchronized void addMouseMotionListener(MouseMotionListener l) 

Source Link

Document

Adds the specified mouse motion listener to receive mouse motion events from this component.

Usage

From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java

/**
 * verfgbare Sprachen in Men eintragen Project: SubmatixBTConfigPC Package: de.dmarcini.submatix.pclogger.gui
 * /*w  w w.  j  ava2 s.c  o m*/
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 18.12.2011
 * @param programLocale
 */
private void initLanuageMenu(Locale programLocale) {
    ResourceBundle rb;
    Enumeration<String> enu;
    String key = null;
    String cmd = null;
    try {
        lg.debug("try init language menu...");
        ignoreAction = true;
        // Lies die Resource aus
        rb = ResourceBundle.getBundle("de.dmarcini.submatix.pclogger.lang.languages");
        // Alle KEYS lesen
        enu = rb.getKeys();
        try {
            lg.debug("try init language menuitems...");
            while (enu.hasMoreElements()) {
                JMenuItem menuItem = new JMenuItem();
                key = enu.nextElement();
                cmd = rb.getString(key);
                menuItem.setText(key);
                menuItem.addActionListener(this);
                menuItem.setActionCommand(cmd);
                menuItem.addMouseMotionListener(this);
                mnLanguages.add(menuItem);
            }
            lg.debug("try init language menuitems...done");
        } catch (NullPointerException ex) {
            lg.error("NULL POINTER EXCEPTION <" + ex.getMessage() + ">");
            statusTextField.setText("ERROR set language strings");
            System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!");
            System.exit(-1);
        } catch (MissingResourceException ex) {
            lg.error("MISSING RESOURCE EXCEPTION <" + ex.getMessage() + ">");
            statusTextField.setText("ERROR set language strings");
            System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!");
            System.exit(-1);
        } catch (ClassCastException ex) {
            lg.error("CLASS CAST EXCEPTION <" + ex.getMessage() + ">");
            statusTextField.setText("ERROR set language strings");
            System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!");
            System.exit(-1);
        } finally {
            ignoreAction = false;
        }
    } catch (NullPointerException ex) {
        lg.error("NULL POINTER EXCEPTION <" + ex.getMessage() + ">");
        statusTextField.setText("ERROR set language strings");
        System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!");
        System.exit(-1);
    } catch (MissingResourceException ex) {
        lg.error("MISSING RESOURCE EXCEPTION <" + ex.getMessage() + ">");
        statusTextField.setText("ERROR set language strings - the given key can be found");
        System.out.println(
                "ERROR set language strings - the given key can be found <" + ex.getMessage() + "> ABORT!");
        System.exit(-1);
    } catch (ClassCastException ex) {
        lg.error("CLASS CAST EXCEPTION <" + ex.getMessage() + ">");
        statusTextField.setText("ERROR set language strings");
        System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!");
        System.exit(-1);
    } finally {
        ignoreAction = false;
    }
    lg.debug("try init language menu...done");
}