本文整理汇总了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 };
}
示例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;
}
}
}