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


Java JTextComponent.setActionMap方法代码示例

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


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

示例1: 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

示例2: 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


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