Example usage for javax.swing JMenu getMenuKeyListeners

List of usage examples for javax.swing JMenu getMenuKeyListeners

Introduction

In this page you can find the example usage for javax.swing JMenu getMenuKeyListeners.

Prototype

@BeanProperty(bound = false)
public MenuKeyListener[] getMenuKeyListeners() 

Source Link

Document

Returns an array of all the MenuKeyListeners added to this JMenuItem with addMenuKeyListener().

Usage

From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java

/**
 * Copies the items from the specified menu and creates a new menu.
 *
 * @param original The menu to handle./* www.j  a  va  2 s . c o m*/
 * @return See above.
 */
private JMenu copyItemsFromMenu(JMenu original) {
    Component[] comps = original.getPopupMenu().getComponents();
    JMenu menu = new JMenu();
    menu.setText(original.getText());
    menu.setToolTipText(original.getToolTipText());
    ActionListener[] al = original.getActionListeners();
    for (int j = 0; j < al.length; j++)
        menu.addActionListener(al[j]);
    MenuKeyListener[] mkl = original.getMenuKeyListeners();
    for (int j = 0; j < mkl.length; j++)
        menu.addMenuKeyListener(mkl[j]);
    MenuListener[] ml = original.getMenuListeners();
    for (int j = 0; j < ml.length; j++)
        menu.addMenuListener(ml[j]);
    for (int i = 0; i < comps.length; i++) {
        if (comps[i] instanceof JMenu) {
            menu.add(copyItemsFromMenu((JMenu) comps[i]));
        } else if (comps[i] instanceof JMenuItem) {
            menu.add(copyItem((JMenuItem) comps[i]));
        } else if (comps[i] instanceof JSeparator) {
            menu.add(new JSeparator(JSeparator.HORIZONTAL));
        }
    }
    return menu;
}