Example usage for javax.swing.text DefaultEditorKit selectionPreviousWordAction

List of usage examples for javax.swing.text DefaultEditorKit selectionPreviousWordAction

Introduction

In this page you can find the example usage for javax.swing.text DefaultEditorKit selectionPreviousWordAction.

Prototype

String selectionPreviousWordAction

To view the source code for javax.swing.text DefaultEditorKit selectionPreviousWordAction.

Click Source Link

Document

Name of the Action for moving the selection to the beginning of the previous word, extending the selection.

Usage

From source file:com.mirth.connect.client.ui.Mirth.java

/**
 * Create the alternate key bindings for the menu shortcut key mask. This is called if the menu
 * shortcut key mask is not the CTRL key (i.e. COMMAND on OSX)
 *///from w w w  .  j av a 2s  . com
private static void createAlternateKeyBindings() {
    int acceleratorKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    // Add the common KeyBindings for macs
    KeyBinding[] defaultBindings = {
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_C, acceleratorKey), DefaultEditorKit.copyAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, acceleratorKey), DefaultEditorKit.pasteAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_X, acceleratorKey), DefaultEditorKit.cutAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_A, acceleratorKey),
                    DefaultEditorKit.selectAllAction),
            // deleteNextWordAction and deletePrevWordAction were not available in Java 1.5
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, acceleratorKey),
                    DefaultEditorKit.deleteNextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, acceleratorKey),
                    DefaultEditorKit.deletePrevWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey),
                    DefaultEditorKit.nextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey),
                    DefaultEditorKit.nextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey),
                    DefaultEditorKit.previousWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey),
                    DefaultEditorKit.previousWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionNextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionNextWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionPreviousWordAction),
            new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, acceleratorKey | InputEvent.SHIFT_MASK),
                    DefaultEditorKit.selectionPreviousWordAction) };

    keyMapBindings(new javax.swing.JTextField(), defaultBindings);
    keyMapBindings(new javax.swing.JPasswordField(), defaultBindings);
    keyMapBindings(new javax.swing.JTextPane(), defaultBindings);
    keyMapBindings(new javax.swing.JTextArea(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextField(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthPasswordField(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextPane(), defaultBindings);
    keyMapBindings(new com.mirth.connect.client.ui.components.MirthTextArea(), defaultBindings);
}