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


Java JTextComponent.getInputMap方法代码示例

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


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

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

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

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

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


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