Java Code Examples for javax.swing.JComponent#WHEN_FOCUSED

The following examples show how to use javax.swing.JComponent#WHEN_FOCUSED . 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
/**
 * Return JTree's input map.
 */
protected InputMap getInputMap(int condition)
{
	InputMap map = super.getInputMap(condition);

	if (condition == JComponent.WHEN_FOCUSED && map != null)
	{
		map.put(KeyStroke.getKeyStroke("control S"), "save");
		map.put(KeyStroke.getKeyStroke("control shift S"), "saveAs");
		map.put(KeyStroke.getKeyStroke("control N"), "new");
		map.put(KeyStroke.getKeyStroke("control O"), "open");

		map.put(KeyStroke.getKeyStroke("control Z"), "undo");
		map.put(KeyStroke.getKeyStroke("control Y"), "redo");
		map
				.put(KeyStroke.getKeyStroke("control shift V"),
						"selectVertices");
		map.put(KeyStroke.getKeyStroke("control shift E"), "selectEdges");
	}

	return map;
}
 
Example 2
Source Project: iBioSim   File: CloseTabPaneUI.java    License: Apache License 2.0 5 votes vote down vote up
static InputMap getMyInputMap(int condition) {
	if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
		return (InputMap) UIManager.get("TabbedPane.ancestorInputMap");
	}
	else if (condition == JComponent.WHEN_FOCUSED) {
		return (InputMap) UIManager.get("TabbedPane.focusInputMap");
	}
	return null;
}