当前位置: 首页>>代码示例>>Java>>正文


Java ActionMap.get方法代码示例

本文整理汇总了Java中javax.swing.ActionMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java ActionMap.get方法的具体用法?Java ActionMap.get怎么用?Java ActionMap.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.ActionMap的用法示例。


在下文中一共展示了ActionMap.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: installOverrideActionMap

import javax.swing.ActionMap; //导入方法依赖的package包/类
public static ActionMap [] installOverrideActionMap(JTextComponent component) {
    ActionMap origActionMap = component.getActionMap();
    ActionMap actionMap = new ActionMap();
    OverrideAction[] actions = new OverrideAction[]{
        new OverrideAction(TAB),
        new OverrideAction(SHIFT_TAB),
        new OverrideAction(ENTER),
    };

    // Install the actions into new action map
    for (OverrideAction action : actions) {
        Object actionKey = (String) action.getValue(Action.NAME);
        assert (actionKey != null);
        // Translate to the real key in the action map
        actionKey = action.findActionKey(component);
        if (actionKey != null) { // == null may happen during unit tests
            Action origAction = origActionMap.get(actionKey);
            action.putValue(ORIGINAL_ACTION_PROPERTY, origAction);
            actionMap.put(actionKey, action);
        }
    }
    actionMap.setParent(origActionMap);
    // Install the new action map and return the original action map
    component.setActionMap(actionMap);
    return new ActionMap [] { origActionMap, actionMap };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:TextRegionManager.java

示例2: findAction

import javax.swing.ActionMap; //导入方法依赖的package包/类
/*** Finds an action that we should delegate to
 * @return the action or null
 */
private Action findAction() {
    Collection<? extends ActionMap> c = result != null ? result.allInstances() : Collections.<ActionMap>emptySet();

    if (!c.isEmpty()) {
        Object key = delegate.getActionMapKey();
        for (ActionMap map : c) {
            Action action = map.get(key);
            if (action != null) {
                return action;
            }
        }
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CallbackSystemAction.java

示例3: sendAction

import javax.swing.ActionMap; //导入方法依赖的package包/类
private void sendAction(final Object key) throws Exception {
    class Process implements Runnable {
        @Override
        public void run() {
            final ActionMap map = treeView.tree.getActionMap();
            Action a = map.get(key);
            String all = Arrays.toString(map.allKeys()).replace(',', '\n');
            
            assertNotNull("Action for key " + key + " found: " + all, a);
            a.actionPerformed(new ActionEvent(treeView.tree, 0, null));
        }
    }
    Process processEvent = new Process();
    LOG.log(Level.INFO, "Sending action {0}", key);
    SwingUtilities.invokeAndWait(processEvent);
    LOG.log(Level.INFO, "Action {0} send", key);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:NavigationTreeViewTest.java

示例4: init

import javax.swing.ActionMap; //导入方法依赖的package包/类
private void init() {
    initialized = true;
    setDefaultRenderer(Object.class, new DefaultOutlineCellRenderer());
    ActionMap am = getActionMap();
    //make rows expandable with left/rigt arrow keys
    Action a = am.get("selectNextColumn"); //NOI18N
    am.put("selectNextColumn", new ExpandAction(true, a)); //NOI18N
    a = am.get("selectPreviousColumn"); //NOI18N
    am.put("selectPreviousColumn", new ExpandAction(false, a)); //NOI18N
    getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (getSelectedRowCount() == 1) {
                selectedRow = getSelectedRow();
            } else {
                selectedRow = -1;
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:Outline.java

示例5: build

import javax.swing.ActionMap; //导入方法依赖的package包/类
/**
 * This method builds the popup menu.
 */
private void build(ActionMap actionMap) {
    
    popupPresenter = new JPopupMenu();
    
    cutAction = actionMap.get(DefaultEditorKit.cutAction);
    copyAction = actionMap.get(DefaultEditorKit.copyAction);
    pasteAction = actionMap.get(DefaultEditorKit.pasteAction);
    selectAllAction = actionMap.get(DefaultEditorKit.selectAllAction);
    
    popupPresenter.add(createMenuItem("CTL_MenuItem_Cut", KeyEvent.VK_X, cutAction));
    popupPresenter.add(createMenuItem("CTL_MenuItem_Copy", KeyEvent.VK_C, copyAction));
    popupPresenter.add(createMenuItem("CTL_MenuItem_Paste", KeyEvent.VK_V, pasteAction));
    popupPresenter.addSeparator();
    popupPresenter.add(createMenuItem("CTL_MenuItem_SelectAll", KeyEvent.VK_A, selectAllAction));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CommitPopupBuilder.java

示例6: findActionFromMap

import javax.swing.ActionMap; //导入方法依赖的package包/类
/** Finds paste action from provided map. */
private static Action findActionFromMap(ActionMap map) {
    if (map != null) {
        return map.get(DefaultEditorKit.pasteAction);
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:PasteAction.java

示例7: findGlobalAction

import javax.swing.ActionMap; //导入方法依赖的package包/类
public Action findGlobalAction(Object key, boolean surviveFocusChange) {
    // search action in all action maps from global context
    Action a = null;
    for (Reference<ActionMap> ref : actionMaps) {
        ActionMap am = ref.get();
        a = am == null ? null : am.get(key);
        if (a != null) {
            break;
        }
    }

    if (surviveFocusChange) {
        if (a == null) {
            a = survive.get(key);

            if (a != null) {
                a = ((WeakAction) a).getDelegate();
            }

            if (err.isLoggable(Level.FINE)) {
                err.fine("No action for key: " + key + " using delegate: " + a); // NOI18N
            }
        } else {
            if (err.isLoggable(Level.FINE)) {
                err.fine("New action for key: " + key + " put: " + a);
            }

            survive.put(key, new WeakAction(a));
        }
    }

    if (err.isLoggable(Level.FINE)) {
        err.fine("Action for key: " + key + " is: " + a); // NOI18N
    }

    return a;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:CallbackSystemAction.java

示例8: playSound

import javax.swing.ActionMap; //导入方法依赖的package包/类
/**
 * Helper method to play a named sound.
 *
 * @param c JComponent to play the sound for.
 * @param actionKey Key for the sound.
 */
static void playSound(JComponent c, Object actionKey) {
    LookAndFeel laf = UIManager.getLookAndFeel();
    if (laf instanceof BasicLookAndFeel) {
        ActionMap map = c.getActionMap();
        if (map != null) {
            Action audioAction = map.get(actionKey);
            if (audioAction != null) {
                // pass off firing the Action to a utility method
                ((BasicLookAndFeel)laf).playSound(audioAction);
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:BasicLookAndFeel.java

示例9: actionPerformed

import javax.swing.ActionMap; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    if (isEditing() || editorComp != null) {
        removeEditor();
        return;
    } else {
        Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        
        InputMap imp = getRootPane().getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        ActionMap am = getRootPane().getActionMap();
        
        KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
        Object key = imp.get(escape);
        if (key == null) {
            //Default for NbDialog
            key = "Cancel";
        }
        if (key != null) {
            Action a = am.get(key);
            if (a != null) {
                String commandKey = (String)a.getValue(Action.ACTION_COMMAND_KEY);
                if (commandKey == null) {
                    commandKey = key.toString();
                }
                a.actionPerformed(new ActionEvent(this,
                ActionEvent.ACTION_PERFORMED, commandKey)); //NOI18N
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ETable.java

示例10: printActionMap

import javax.swing.ActionMap; //导入方法依赖的package包/类
private void printActionMap(ActionMap actionMap) {
System.out.printf("-------- Original ActionMap -----------\n");
Object[] allkeys = actionMap.allKeys();
if (allkeys == null) {
    System.out.printf("\t<empty>\n");
} else {
    for (Object k : allkeys) {
	Action a = actionMap.get(k);
	System.out.printf("\t%s %s\n", k, a);
    }
}
System.out.printf("%s\n", actionMap);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:Terminal.java

示例11: setMenu

import javax.swing.ActionMap; //导入方法依赖的package包/类
/** Sets the state of JMenuItem*/
protected @Override void setMenu(){
    
    ActionMap am = getContextActionMap();
    Action action = null;
    if (am != null) {
        action = am.get(getActionName());
    }
    
    JMenuItem presenter = getMenuPresenter();
    Action presenterAction = presenter.getAction();
    if (presenterAction == null){
        presenter.setAction(this);
        presenter.setToolTipText(null); /* bugfix #62872 */ 
        menuInitialized = false;
    } 
    else {
        if (!this.equals(presenterAction)){
            presenter.setAction(this);
            presenter.setToolTipText(null); /* bugfix #62872 */
            menuInitialized = false;
        }
    }

    if (!menuInitialized){
        Mnemonics.setLocalizedText(presenter, getMenuItemText());
        menuInitialized = true;
    }

    presenter.setEnabled(action != null);
    JTextComponent comp = Utilities.getFocusedComponent();
    if (comp != null && comp instanceof JEditorPane){
        addAccelerators(this, presenter, comp);
    } else {
        presenter.setAccelerator(getDefaultAccelerator());
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:CompletionActionsMainMenu.java

示例12: get

import javax.swing.ActionMap; //导入方法依赖的package包/类
@Override
public Action get(Object key) {
    ActionMap m;

    if (delegate == null) {
        JComponent comp = getComponent();
        if (comp == null) {
            m = null;
        } else {
            m = comp.getActionMap();
        }
    } else {
        m = delegate;
    }

    if (m != null) {
        Action a = m.get(key);

        if (a != null) {
            return a;
        }
    }

    Component owner = GlobalActionContextImpl.findFocusOwner();
    Action found = null;

    while ((owner != null) && (owner != getComponent())) {
        if ((found == null) && (owner instanceof JComponent)) {
            m = ((JComponent) owner).getActionMap();

            if (m != null) {
                found = m.get(key);
            }
        }

        owner = owner.getParent();
    }

    return (owner == getComponent()) ? found : null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:DelegateActionMap.java

示例13: getDefaultEnterAction

import javax.swing.ActionMap; //导入方法依赖的package包/类
private Action getDefaultEnterAction(JTextComponent tc) {
	ActionMap am = tc.getActionMap();
	return am.get(DefaultEditorKit.insertBreakAction);
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:5,代码来源:ParameterizedCompletionContext.java

示例14: installKeyBindings

import javax.swing.ActionMap; //导入方法依赖的package包/类
/**
 * Registers keyboard actions to listen for in the text component and
 * intercept.
 *
 * @see #uninstallKeyBindings()
 */
private void installKeyBindings() {

	if (AutoCompletion.getDebug()) {
		System.out.println("PopupWindow: Installing keybindings");
	}
	if (keyBindingsInstalled) {
		System.err.println("Error: key bindings were already installed");
		Thread.dumpStack();
		return;
	}

	if (escapeKap==null) { // Lazily create actions.
		createKeyActionPairs();
	}

	JTextComponent comp = ac.getTextComponent();
	InputMap im = comp.getInputMap();
	ActionMap am = comp.getActionMap();

	replaceAction(im, am, KeyEvent.VK_ESCAPE, escapeKap, oldEscape);
	if (AutoCompletion.getDebug() && oldEscape.action==escapeKap.action) {
		Thread.dumpStack();
	}
	replaceAction(im, am, KeyEvent.VK_UP, upKap, oldUp);
	replaceAction(im, am, KeyEvent.VK_LEFT, leftKap, oldLeft);
	replaceAction(im, am, KeyEvent.VK_DOWN, downKap, oldDown);
	replaceAction(im, am, KeyEvent.VK_RIGHT, rightKap, oldRight);
	replaceAction(im, am, KeyEvent.VK_ENTER, enterKap, oldEnter);
	replaceAction(im, am, KeyEvent.VK_TAB, tabKap, oldTab);
	replaceAction(im, am, KeyEvent.VK_HOME, homeKap, oldHome);
	replaceAction(im, am, KeyEvent.VK_END, endKap, oldEnd);
	replaceAction(im, am, KeyEvent.VK_PAGE_UP, pageUpKap, oldPageUp);
	replaceAction(im, am, KeyEvent.VK_PAGE_DOWN, pageDownKap, oldPageDown);

	// Make Ctrl+C copy from description window.  This isn't done
	// automagically because the desc. window is not focusable, and copying
	// from text components can only be done from focused components.
	KeyStroke ks = getCopyKeyStroke();
	oldCtrlC.key = im.get(ks);
	im.put(ks, ctrlCKap.key);
	oldCtrlC.action = am.get(ctrlCKap.key);
	am.put(ctrlCKap.key, ctrlCKap.action);

	comp.addCaretListener(this);

	keyBindingsInstalled = true;

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:55,代码来源:AutoCompletePopupWindow.java

示例15: installKeyBindings

import javax.swing.ActionMap; //导入方法依赖的package包/类
/**
 * Installs key bindings on the text component that facilitate the user
 * editing this completion's parameters.
 *
 * @see #uninstallKeyBindings()
 */
private void installKeyBindings() {

	if (AutoCompletion.getDebug()) {
		System.out.println("CompletionContext: Installing keybindings");
	}

	JTextComponent tc = ac.getTextComponent();
	InputMap im = tc.getInputMap();
	ActionMap am = tc.getActionMap();

	KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
	oldTabKey = im.get(ks);
	im.put(ks, IM_KEY_TAB);
	oldTabAction = am.get(IM_KEY_TAB);
	am.put(IM_KEY_TAB, new NextParamAction());

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK);
	oldShiftTabKey = im.get(ks);
	im.put(ks, IM_KEY_SHIFT_TAB);
	oldShiftTabAction = am.get(IM_KEY_SHIFT_TAB);
	am.put(IM_KEY_SHIFT_TAB, new PrevParamAction());

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0);
	oldUpKey = im.get(ks);
	im.put(ks, IM_KEY_UP);
	oldUpAction = am.get(IM_KEY_UP);
	am.put(IM_KEY_UP, new NextChoiceAction(-1, oldUpAction));

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0);
	oldDownKey = im.get(ks);
	im.put(ks, IM_KEY_DOWN);
	oldDownAction = am.get(IM_KEY_DOWN);
	am.put(IM_KEY_DOWN, new NextChoiceAction(1, oldDownAction));

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
	oldEnterKey = im.get(ks);
	im.put(ks, IM_KEY_ENTER);
	oldEnterAction = am.get(IM_KEY_ENTER);
	am.put(IM_KEY_ENTER, new GotoEndAction());

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
	oldEscapeKey = im.get(ks);
	im.put(ks, IM_KEY_ESCAPE);
	oldEscapeAction = am.get(IM_KEY_ESCAPE);
	am.put(IM_KEY_ESCAPE, new HideAction());

	char end = pc.getProvider().getParameterListEnd();
	ks = KeyStroke.getKeyStroke(end);
	oldClosingKey = im.get(ks);
	im.put(ks, IM_KEY_CLOSING);
	oldClosingAction = am.get(IM_KEY_CLOSING);
	am.put(IM_KEY_CLOSING, new ClosingAction());

}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:61,代码来源:ParameterizedCompletionContext.java


注:本文中的javax.swing.ActionMap.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。