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


Java JTextComponent.getActionMap方法代码示例

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


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

示例1: detachSystemActionPerformer

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private void detachSystemActionPerformer(JTextComponent c){
    if (c == null) return;

    Action action = getEditorAction(c);
    if (action == null) return;

    Action globalSystemAction = getSystemAction(c);
    if (globalSystemAction == null) return;

    if (globalSystemAction instanceof CallbackSystemAction){
        Object key = ((CallbackSystemAction)globalSystemAction).getActionMapKey();
        ActionMap am = c.getActionMap();
        if (am != null) {
            Object ea = am.get(key);
            if (action.equals(ea)) {
                am.remove(key);
            }
        }
    }                        
                        
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:NbEditorUI.java

示例2: installOverrideActionMap

import javax.swing.text.JTextComponent; //导入方法依赖的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

示例3: removeGroupsUpdate

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
private void removeGroupsUpdate() {
    if (editGroups.size() == 0) {
        JTextComponent component = component();
        if (doc instanceof BaseDocument) {
            BaseDocument bdoc = (BaseDocument) doc;
            // Add the listener to allow doc syncing modifications
            // The listener is never removed (since this object is a property of the document)
            bdoc.removePostModificationDocumentListener(DocListener.INSTANCE);
            bdoc.removeUpdateDocumentListener(UpdateDocListener.INSTANCE);
        }
        activeTextSync = null;
        componentRef = null;

        if (overridingKeys) {
            overridingKeys = false;
            component.removeKeyListener(OverrideKeysListener.INSTANCE);

            // check if the action map is still our overrideActionMap
            if (overrideActionMap != component.getActionMap()) {
                LOG.warning("The action map got tampered with! component=" //NOI18
                    + component.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(component)) //NOI18N
                    + "; doc=" + component.getDocument()); //NOI18N
            } else {
                component.setActionMap(origActionMap);
            }

            overrideActionMap.clear();
            origActionMap = null;
            overrideActionMap = null;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:TextRegionManager.java

示例4: uninstallKeyBindings

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
 * Stops intercepting certain keystrokes from the text component.
 *
 * @see #installKeyBindings()
 */
private void uninstallKeyBindings() {

	if (AutoCompletion.getDebug()) {
		System.out.println("PopupWindow: Removing keybindings");
	}
	if (!keyBindingsInstalled) {
		return;
	}

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

	putBackAction(im, am, KeyEvent.VK_ESCAPE, oldEscape);
	putBackAction(im, am, KeyEvent.VK_UP, oldUp);
	putBackAction(im, am, KeyEvent.VK_DOWN, oldDown);
	putBackAction(im, am, KeyEvent.VK_LEFT, oldLeft);
	putBackAction(im, am, KeyEvent.VK_RIGHT, oldRight);
	putBackAction(im, am, KeyEvent.VK_ENTER, oldEnter);
	putBackAction(im, am, KeyEvent.VK_TAB, oldTab);
	putBackAction(im, am, KeyEvent.VK_HOME, oldHome);
	putBackAction(im, am, KeyEvent.VK_END, oldEnd);
	putBackAction(im, am, KeyEvent.VK_PAGE_UP, oldPageUp);
	putBackAction(im, am, KeyEvent.VK_PAGE_DOWN, oldPageDown);

	// Ctrl+C
	KeyStroke ks = getCopyKeyStroke();
	am.put(im.get(ks), oldCtrlC.action); // Original action
	im.put(ks, oldCtrlC.key); // Original key

	comp.removeCaretListener(this);

	keyBindingsInstalled = false;

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

示例5: installKeyBindings

import javax.swing.text.JTextComponent; //导入方法依赖的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

示例6: installKeyBindings

import javax.swing.text.JTextComponent; //导入方法依赖的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

示例7: uninstallKeyBindings

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/**
 * Removes the key bindings we installed.
 *
 * @see #installKeyBindings()
 */
private void uninstallKeyBindings() {

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

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

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

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

	ks = KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0);
	im.put(ks, oldUpKey);
	am.put(IM_KEY_UP, oldUpAction);

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

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

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

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

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

示例8: getDefaultEnterAction

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


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