當前位置: 首頁>>代碼示例>>Java>>正文


Java InputMap.setParent方法代碼示例

本文整理匯總了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);
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:Terminal.java

示例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;
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:24,代碼來源:RSyntaxTextAreaUI.java


注:本文中的javax.swing.InputMap.setParent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。