use of javax.swing.KeyStroke in project binnavi by google.
the class JHexView method initHotkeys.
/**
* Initializes the keys that can be used by the user inside the component.
*/
private void initHotkeys() {
// Don't change focus on TAB
setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, new HashSet<KeyStroke>());
final InputMap inputMap = this.getInputMap();
final ActionMap actionMap = getActionMap();
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "LEFT");
actionMap.put("LEFT", m_leftAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, InputEvent.SHIFT_DOWN_MASK), "shift LEFT");
actionMap.put("shift LEFT", m_leftAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "RIGHT");
actionMap.put("RIGHT", m_rightAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.SHIFT_DOWN_MASK), "shift RIGHT");
actionMap.put("shift RIGHT", m_rightAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "UP");
actionMap.put("UP", m_upAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_DOWN_MASK), "shift UP");
actionMap.put("shift UP", m_upAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "DOWN");
actionMap.put("DOWN", m_downAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.SHIFT_DOWN_MASK), "shift DOWN");
actionMap.put("shift DOWN", m_downAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "PAGE_DOWN");
actionMap.put("PAGE_DOWN", m_pageDownAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, InputEvent.SHIFT_DOWN_MASK), "shift PAGE_DOWN");
actionMap.put("shift PAGE_DOWN", m_pageDownAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "PAGE_UP");
actionMap.put("PAGE_UP", m_pageUpAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.SHIFT_DOWN_MASK), "shift PAGE_UP");
actionMap.put("shift PAGE_UP", m_pageUpAction);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "TAB");
actionMap.put("TAB", m_tabAction);
}
use of javax.swing.KeyStroke in project jmeter by apache.
the class MainFrame method addQuickComponentHotkeys.
private void addQuickComponentHotkeys(JTree treevar) {
Action quickComponent = new QuickComponent("Quick Component");
InputMap inputMap = treevar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
KeyStroke[] keyStrokes = new KeyStroke[] { KeyStrokes.CTRL_0, KeyStrokes.CTRL_1, KeyStrokes.CTRL_2, KeyStrokes.CTRL_3, KeyStrokes.CTRL_4, KeyStrokes.CTRL_5, KeyStrokes.CTRL_6, KeyStrokes.CTRL_7, KeyStrokes.CTRL_8, KeyStrokes.CTRL_9 };
for (int n = 0; n < keyStrokes.length; n++) {
treevar.getActionMap().put(ActionNames.QUICK_COMPONENT + String.valueOf(n), quickComponent);
inputMap.put(keyStrokes[n], ActionNames.QUICK_COMPONENT + String.valueOf(n));
}
}
use of javax.swing.KeyStroke in project jmeter by apache.
the class TextComponentUI method installUndo.
/**
* Installs an undo manager and keyboard shortcuts to a text component
* @param component JTextField or JTextArea
*/
@API(since = "5.3", status = API.Status.INTERNAL)
public void installUndo(JTextComponent component) {
// JMeter reuses Swing JComponents, so when user switches to another component,
// JComponent#name is updated. However, we don't want user to be able to "undo" that
// So when tree selection is changed, we increase undoEpoch. That enables
// UndoManagers to treat that as "end of undo history"
UndoManager manager = new DefaultUndoManager(undoEpoch);
manager.setLimit(200);
component.addPropertyChangeListener("document", new AddUndoableEditListenerPropertyChangeListener(manager));
component.getActionMap().put("undo", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (manager.canUndo()) {
manager.undo();
}
}
});
component.getActionMap().put("redo", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
if (manager.canRedo()) {
manager.redo();
}
}
});
KeyStroke commandZ = KeyStroke.getKeyStroke(KeyEvent.VK_Z, COMMAND_KEY);
component.getInputMap().put(commandZ, "undo");
KeyStroke shiftCommandZ = KeyStroke.getKeyStroke(KeyEvent.VK_Z, COMMAND_KEY | InputEvent.SHIFT_DOWN_MASK);
component.getInputMap().put(shiftCommandZ, "redo");
}
use of javax.swing.KeyStroke in project GCViewer by chewiebug.
the class ScreenCenteredDialog method createRootPane.
protected JRootPane createRootPane() {
KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
JRootPane rootPane = new JRootPane();
rootPane.registerKeyboardAction(this, escapeStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
rootPane.registerKeyboardAction(this, enterStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
return rootPane;
}
use of javax.swing.KeyStroke in project GDSC-SMLM by aherbert.
the class TableColumnAdjuster method installToggleAction.
/*
* Update the input and action maps with new ToggleAction
*/
private void installToggleAction(boolean isToggleDynamic, boolean isToggleLarger, String key, String keyStroke) {
final Action action = new ToggleAction(isToggleDynamic, isToggleLarger);
final KeyStroke ks = KeyStroke.getKeyStroke(keyStroke);
table.getInputMap().put(ks, key);
table.getActionMap().put(key, action);
}
Aggregations