use of javax.swing.KeyStroke in project jadx by skylot.
the class TextStandardActions method addKeyActions.
private void addKeyActions() {
KeyStroke undoKey = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK);
textComponent.getInputMap().put(undoKey, undoAction);
KeyStroke redoKey = KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_MASK);
textComponent.getInputMap().put(redoKey, redoAction);
}
use of javax.swing.KeyStroke in project jgnash by ccavanaugh.
the class Resource method getKeyStroke.
/**
* Gets a localized keystroke.
*
* @param key KeyStroke key
* @return localized KeyStroke
*/
public static KeyStroke getKeyStroke(final String key) {
String value = ResourceUtils.getString(key);
// if working on an QSX system, use the meta key instead of the control key
if (value != null && value.contains("control") && OS.isSystemOSX()) {
value = value.replace("control", "meta");
}
final KeyStroke keyStroke = KeyStroke.getKeyStroke(value);
if (keyStroke == null && value != null && !value.isEmpty()) {
Logger.getLogger(Resource.class.getName()).log(Level.WARNING, "The value ''{0}'' for key ''{1}'' is not valid.", new Object[] { value, key });
}
return keyStroke;
}
use of javax.swing.KeyStroke in project jabref by JabRef.
the class FindUnlinkedFilesDialog method createRootPane.
/**
* Close dialog when pressing escape
*/
@Override
protected JRootPane createRootPane() {
ActionListener actionListener = actionEvent -> setVisible(false);
JRootPane rPane = new JRootPane();
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
rPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
return rPane;
}
use of javax.swing.KeyStroke in project jabref by JabRef.
the class EmacsKeyBindings method createBackup.
private static void createBackup() {
Keymap oldBackup = JTextComponent.getKeymap(EmacsKeyBindings.JTCS[0].getClass().getName());
if (oldBackup != null) {
// if there is already a backup, do not create a new backup
return;
}
for (JTextComponent jtc : EmacsKeyBindings.JTCS) {
Keymap orig = jtc.getKeymap();
Keymap backup = JTextComponent.addKeymap(jtc.getClass().getName(), null);
Action[] bound = orig.getBoundActions();
for (Action aBound : bound) {
KeyStroke[] strokes = orig.getKeyStrokesForAction(aBound);
for (KeyStroke stroke : strokes) {
backup.addActionForKeyStroke(stroke, aBound);
}
}
backup.setDefaultAction(orig.getDefaultAction());
}
}
use of javax.swing.KeyStroke in project jabref by JabRef.
the class EmacsKeyBindings method unload.
/**
* Restores the original keybindings for the concrete subclasses of
* {@link JTextComponent}.
*/
public static void unload() {
for (int i = 0; i < EmacsKeyBindings.JTCS.length; i++) {
Keymap backup = JTextComponent.getKeymap(EmacsKeyBindings.JTCS[i].getClass().getName());
if (backup != null) {
Keymap current = EmacsKeyBindings.JTCS[i].getKeymap();
current.removeBindings();
Action[] bound = backup.getBoundActions();
for (Action aBound : bound) {
KeyStroke[] strokes = backup.getKeyStrokesForAction(bound[i]);
for (KeyStroke stroke : strokes) {
current.addActionForKeyStroke(stroke, aBound);
}
}
current.setDefaultAction(backup.getDefaultAction());
}
}
}
Aggregations