本文整理匯總了Java中javax.swing.InputMap.setParent方法的典型用法代碼示例。如果您正苦於以下問題:Java InputMap.setParent方法的具體用法?Java InputMap.setParent怎麽用?Java InputMap.setParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.InputMap
的用法示例。
在下文中一共展示了InputMap.setParent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupKeymap
import javax.swing.InputMap; //導入方法依賴的package包/類
private void setupKeymap(Set<Action> actions) {
JComponent comp = term.getScreen();
ActionMap actionMap = comp.getActionMap();
ActionMap newActionMap = new ActionMap();
newActionMap.setParent(actionMap);
printActionMap(actionMap);
InputMap inputMap = comp.getInputMap();
InputMap newInputMap = new InputMap();
newInputMap.setParent(inputMap);
Set<KeyStroke> passKeystrokes = new HashSet<KeyStroke>();
for (Action a : actions) {
String name = (String) a.getValue(Action.NAME);
KeyStroke accelerator = (KeyStroke) a.getValue(Action.ACCELERATOR_KEY);
System.out.printf("Registering %s for %s\n", accelerator, name);
if (accelerator == null)
continue;
newInputMap.put(accelerator, name);
newActionMap.put(name, a);
passKeystrokes.add(accelerator);
}
comp.setActionMap(newActionMap);
comp.setInputMap(JComponent.WHEN_FOCUSED, newInputMap);
term.setKeyStrokeSet((HashSet) passKeystrokes);
}
示例2: getRTextAreaInputMap
import javax.swing.InputMap; //導入方法依賴的package包/類
/**
* Get the InputMap to use for the UI.<p>
*
* This method is not named <code>getInputMap()</code> because there is
* a package-private method in <code>BasicTextAreaUI</code> with that name.
* Thus, creating a new method with that name causes certain compilers to
* issue warnings that you are not actually overriding the original method
* (since it is package-private).
*/
@Override
protected InputMap getRTextAreaInputMap() {
InputMap map = new InputMapUIResource();
InputMap shared = (InputMap)UIManager.get(SHARED_INPUT_MAP_NAME);
if (shared==null) {
shared = new RSyntaxTextAreaDefaultInputMap();
UIManager.put(SHARED_INPUT_MAP_NAME, shared);
}
//KeyStroke[] keys = shared.allKeys();
//for (int i=0; i<keys.length; i++)
// System.err.println(keys[i] + " -> " + shared.get(keys[i]));
map.setParent(shared);
return map;
}