Example usage for javax.swing JMenuItem getAccessibleContext

List of usage examples for javax.swing JMenuItem getAccessibleContext

Introduction

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

Prototype

@BeanProperty(bound = false)
public AccessibleContext getAccessibleContext() 

Source Link

Document

Returns the AccessibleContext associated with this JMenuItem.

Usage

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

/**
 * Creates a JMenuItem.//from   w  w  w  .  j  a  v  a 2s  .c  om
 * @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 JMenuItem createMenuItemWithAction(final JPopupMenu menu, final String label,
        final String mnemonic, final String accessibleDescription, final boolean enabled, final Action action) {
    JMenuItem mi = new JMenuItem(action);
    mi.setText(label);
    if (menu != null) {
        menu.add(mi);
    }
    if (isNotEmpty(mnemonic)) {
        mi.setMnemonic(mnemonic.charAt(0));
    }
    if (isNotEmpty(accessibleDescription)) {
        mi.getAccessibleContext().setAccessibleDescription(accessibleDescription);
    }

    if (action != null) {
        action.addPropertyChangeListener(new MenuItemPropertyChangeListener(mi));
        action.setEnabled(enabled);
    }

    return mi;
}

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

/**
 * Creates a JMenuItem.//from  ww w .ja  v a 2 s. com
 * @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 JMenuItem createMenuItemWithAction(final JMenu menu, final String label, final String mnemonic,
        final String accessibleDescription, final boolean enabled, final Action action) {
    JMenuItem mi = new JMenuItem(action);
    mi.setText(label);

    if (menu != null) {
        menu.add(mi);
    }
    if (isNotEmpty(mnemonic)) {
        mi.setMnemonic(mnemonic.charAt(0));
    }
    if (isNotEmpty(accessibleDescription)) {
        mi.getAccessibleContext().setAccessibleDescription(accessibleDescription);
    }

    if (action != null) {
        action.addPropertyChangeListener(new MenuItemPropertyChangeListener(mi));
        action.setEnabled(enabled);
    }

    return mi;
}

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

/**
 * Creates a JMenuItem.//from  w ww  . j a  v a 2 s. com
 * @param key the label key 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 JMenuItem createLocalizedMenuItem(final String key, final String mnemonic,
        final String accessibleDescription, final boolean enabled, final ActionListener al) {
    JMenuItem mi = new JMenuItem(getResourceString(key));
    if (isNotEmpty(mnemonic)) {
        String mnu = getResourceString(mnemonic);
        mi.setMnemonic(mnu.charAt(0));
    }
    if (isNotEmpty(accessibleDescription)) {
        String desc = getResourceString(accessibleDescription);
        mi.getAccessibleContext().setAccessibleDescription(desc);
    }
    mi.addActionListener(al);
    mi.setEnabled(enabled);
    return mi;
}