Example usage for javax.swing AbstractAction addPropertyChangeListener

List of usage examples for javax.swing AbstractAction addPropertyChangeListener

Introduction

In this page you can find the example usage for javax.swing AbstractAction addPropertyChangeListener.

Prototype

public synchronized void addPropertyChangeListener(PropertyChangeListener listener) 

Source Link

Document

Adds a PropertyChangeListener to the listener list.

Usage

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Creates a Localized JCheckBoxMenuItem.
 * @param labelKey//from  w  w w .  j  av  a  2s .c o  m
 * @param mnemonicKey
 * @param accessibleDescriptionKey
 * @param enabled
 * @param action
 * @return
 */
public static JCheckBoxMenuItem createLocalizedCheckBoxMenuItem(final String labelKey, final String mnemonicKey,
        final String accessibleDescriptionKey, final boolean enabled, final AbstractAction action) {
    JCheckBoxMenuItem mi = new JCheckBoxMenuItem(getResourceString(labelKey));
    setLocalizedMnemonic(mi, getResourceString(mnemonicKey));

    if (isNotEmpty(accessibleDescriptionKey)) {
        mi.getAccessibleContext().setAccessibleDescription(getResourceString(accessibleDescriptionKey));
    }
    if (action != null) {
        mi.addActionListener(action);
        action.addPropertyChangeListener(new MenuItemPropertyChangeListener(mi));
        action.setEnabled(enabled);
    }

    return mi;
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Creates a JCheckBoxMenuItem./*from  ww  w . jav  a2  s .  c  o  m*/
 * @param menu parent menu
 * @param label the label of the menu item
 * @param mnemonic the mnemonic
 * @param accessibleDescription the accessible Description
 * @param enabled enabled
 * @param action the aciton
 * @return menu item
 */
public static JCheckBoxMenuItem createCheckBoxMenuItem(final JMenu menu, final String label,
        final String mnemonic, final String accessibleDescription, final boolean enabled,
        final AbstractAction action) {
    JCheckBoxMenuItem mi = new JCheckBoxMenuItem(getResourceString(label));
    if (menu != null) {
        menu.add(mi);
    }
    setLocalizedMnemonic(mi, mnemonic);

    if (isNotEmpty(accessibleDescription)) {
        mi.getAccessibleContext().setAccessibleDescription(accessibleDescription);
    }
    if (action != null) {
        mi.addActionListener(action);
        action.addPropertyChangeListener(new MenuItemPropertyChangeListener(mi));
        action.setEnabled(enabled);
    }

    return mi;
}

From source file:edu.ku.brc.ui.UIHelper.java

/**
 * Creates a JRadioButtonMenuItem.//from  w w  w. j a v  a2  s  . c o  m
 * @param menu parent menu
 * @param label the label of the menu item
 * @param mnemonic the mnemonic
 * @param accessibleDescription the accessible Description
 * @param enabled enabled
 * @param action the aciton
 * @return menu item
 */
public static JRadioButtonMenuItem createRadioButtonMenuItem(final JMenu menu, final String label,
        final String mnemonic, final String accessibleDescription, final boolean enabled,
        final AbstractAction action) {
    JRadioButtonMenuItem mi = new JRadioButtonMenuItem(getResourceString(label));
    if (menu != null) {
        menu.add(mi);
    }
    setLocalizedMnemonic(mi, mnemonic);
    if (isNotEmpty(accessibleDescription)) {
        mi.getAccessibleContext().setAccessibleDescription(accessibleDescription);
    }
    if (action != null) {
        mi.addActionListener(action);
        action.addPropertyChangeListener(new MenuItemPropertyChangeListener(mi));
        action.setEnabled(enabled);
    }

    return mi;
}