Java JFrame Parent getInstalledOperation(final RootPaneContainer frame, final Object actionKey, boolean selfOnly)

Here you can find the source of getInstalledOperation(final RootPaneContainer frame, final Object actionKey, boolean selfOnly)

Description

Returns the Action installed under the specified action key in the specified frame.

License

Open Source License

Parameter

Parameter Description
frame The frame in which the action is installed
actionKey The action key to which the action is bound
selfOnly If true, will only check the frame specified in argument for actions bound to the action key. If false, will check any parents of the action map for actions bound to the action key, if none was found in the first one.

Declaration

public static Action getInstalledOperation(final RootPaneContainer frame, final Object actionKey,
        boolean selfOnly) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.Action;
import javax.swing.ActionMap;

import javax.swing.JRootPane;

import javax.swing.RootPaneContainer;

public class Main {
    /**/*from w  w w.  j a  va  2s .c o  m*/
     * Returns the Action installed under the specified action key in the specified frame.
     * 
     * @param frame
     *            The frame in which the action is installed
     * @param actionKey
     *            The action key to which the action is bound
     * @param selfOnly
     *            If true, will only check the frame specified in argument for actions bound
     *            to the action key.
     *            If false, will check any parents of the action map for actions bound to the
     *            action key, if none was found in the first one.
     */
    public static Action getInstalledOperation(final RootPaneContainer frame, final Object actionKey,
            boolean selfOnly) {
        JRootPane root = frame.getRootPane();

        if (selfOnly) {
            ActionMap actionMap = root.getActionMap();
            ActionMap parentMap = actionMap.getParent();

            actionMap.setParent(null);
            Action result = actionMap.get(actionKey);
            actionMap.setParent(parentMap);

            return result;
        } else {
            return root.getActionMap().get(actionKey);
        }
    }
}

Related

  1. fileOpen(Frame parent, String typename, String ext)
  2. findParentDialogOrFrame(Container container)
  3. getFirstParentFrameOrDialog(Component cmp)
  4. getFrame(Component parent)
  5. getFrameParent(Component component)
  6. getParentalFrame(Component n)
  7. getParentFrame(Component component)
  8. getParentFrame(Component component)
  9. getParentFrame(Component parent)