Example usage for javax.swing JMenu getAction

List of usage examples for javax.swing JMenu getAction

Introduction

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

Prototype

public Action getAction() 

Source Link

Document

Returns the currently set Action for this ActionEvent source, or null if no Action is set.

Usage

From source file:Main.java

/**
 * Finds a {@link JMenu} for the given {@link Action} within the given
 * menu./*from w  w  w.  j a  v a  2 s  .c  o  m*/
 *
 * @param menu
 * @param action
 * @return
 */
public static JMenu findMenu(JMenu menu, Action action) {
    if (action.equals(menu.getAction())) {
        return menu;
    }
    for (Component comp : menu.getMenuComponents()) {
        if (comp instanceof JMenu) {
            if (((JMenu) comp).getAction().equals(action)) {
                return (JMenu) comp;
            }
            return findMenu((JMenu) comp, action);
        }
    }
    return null;
}