Java Code Examples for javax.swing.plaf.InputMapUIResource

The following examples show how to use javax.swing.plaf.InputMapUIResource. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: FlatLaf   Source File: FlatInputMaps.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Object createValue( UIDefaults table ) {
	InputMap inputMap = new InputMapUIResource();
	for( Object[] bindings : bindingsArray )
		LookAndFeel.loadKeyBindings( inputMap, bindings );
	return inputMap;
}
 
Example 2
Source Project: iBioSim   Source File: CloseTabPaneUI.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Installs the state needed for mnemonics.
 */
private void initMnemonics() {
	mnemonicToIndexMap = new Hashtable<Integer, Integer>();
	mnemonicInputMap = new InputMapUIResource();
	mnemonicInputMap.setParent(SwingUtilities.getUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT));
	SwingUtilities.replaceUIInputMap(tabPane, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, mnemonicInputMap);
}
 
Example 3
Source Project: stendhal   Source File: StyledLookAndFeel.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * A hack to work around swing hard coding key bindings, and providing
 * no reasonable way to access the native ones. Add new components and
 * key bindings here when mac users report them.
 *
 * @param table A mess of all UI defaults crammed in one hash map
 */
private void restoreSystemKeymaps(UIDefaults table) {
	/*
	 * Input mappings that need to be tuned. the list is not exhaustive and
	 * will likely need more entries when new components start to be used.
	 */
	String[] keys = { "EditorPane.focusInputMap",
			"FormattedTextField.focusInputMap",
			"PasswordField.focusInputMap",
			"TextArea.focusInputMap",
			"TextField.focusInputMap",
			"TextPane.focusInputMap" };

	// Native modifier key. Ctrl for others, cmd on mac
	int modifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();

	for (String key : keys) {
		Object value = table.get(key);
		if (value instanceof InputMapUIResource) {
			InputMapUIResource map = (InputMapUIResource) value;

			// CUT
			remapKey(map, KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK, modifier);

			// COPY
			remapKey(map, KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK, modifier);

			// PASTE
			remapKey(map, KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK, modifier);

			// SELECT ALL
			remapKey(map, KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK, modifier);
		} else {
			Logger.getLogger(StyledLookAndFeel.class).error("Can not modify resource: " + key);
		}
	}
}
 
Example 4
Source Project: stendhal   Source File: StyledLookAndFeel.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Remap a swing default key binding to a native one, if needed.
 *
 * @param map keymap to be modified
 * @param key
 * @param defaultModifier swing default modifier key for the action
 * @param nativeModifier native modifier key for the action
 */
private void remapKey(InputMapUIResource map, int key, int defaultModifier,
		int nativeModifier) {
	KeyStroke defaultKey = KeyStroke.getKeyStroke(key, defaultModifier);
	Object action = map.get(defaultKey);

	KeyStroke nativeKey = KeyStroke.getKeyStroke(key, nativeModifier);
	if (!nativeKey.equals(defaultKey)) {
		map.remove(defaultKey);
		map.put(nativeKey, action);
	}
}
 
Example 5
Source Project: cuba   Source File: App.java    License: Apache License 2.0 4 votes vote down vote up
protected void initLookAndFeelDefaults() {
    InputMapUIResource inputMap =
            (InputMapUIResource) UIManager.getLookAndFeelDefaults().get("FormattedTextField.focusInputMap");
    inputMap.remove(KeyStroke.getKeyStroke("ESCAPE"));
}
 
Example 6
Source Project: tn5250j   Source File: BasicTerminalUI.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected InputMap getInputMap()
{
  InputMap map = new InputMapUIResource();

  return map;
}