Example usage for javax.swing.text DefaultEditorKit backwardAction

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

Introduction

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

Prototype

String backwardAction

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

Click Source Link

Document

Name of the Action for moving the caret logically backward one position.

Usage

From source file:TextComponentDemo.java

protected void addBindings() {
    InputMap inputMap = textPane.getInputMap();

    // Ctrl-b to go backward one character
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_B, Event.CTRL_MASK);
    inputMap.put(key, DefaultEditorKit.backwardAction);

    // Ctrl-f to go forward one character
    key = KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK);
    inputMap.put(key, DefaultEditorKit.forwardAction);

    // Ctrl-p to go up one line
    key = KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK);
    inputMap.put(key, DefaultEditorKit.upAction);

    // Ctrl-n to go down one line
    key = KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK);
    inputMap.put(key, DefaultEditorKit.downAction);
}

From source file:TextComponentDemo.java

protected void addBindings() {
    InputMap inputMap = textPane.getInputMap();

    //Ctrl-b to go backward one character
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_B, Event.CTRL_MASK);
    inputMap.put(key, DefaultEditorKit.backwardAction);

    //Ctrl-f to go forward one character
    key = KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK);
    inputMap.put(key, DefaultEditorKit.forwardAction);

    //Ctrl-p to go up one line
    key = KeyStroke.getKeyStroke(KeyEvent.VK_P, Event.CTRL_MASK);
    inputMap.put(key, DefaultEditorKit.upAction);

    //Ctrl-n to go down one line
    key = KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK);
    inputMap.put(key, DefaultEditorKit.downAction);
}

From source file:DateTimeEditor.java

protected void setupKeymap() {
    Keymap keymap = m_textField.addKeymap("DateTimeKeymap", null);
    keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), m_upAction);
    keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), m_downAction);
    keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0),
            new BackwardAction(DefaultEditorKit.backwardAction));
    keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0),
            new ForwardAction(DefaultEditorKit.forwardAction));
    keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
            new BeginAction(DefaultEditorKit.beginAction));
    keymap.addActionForKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
            new EndAction(DefaultEditorKit.endAction));
    m_textField.setKeymap(keymap);/*from   www  . j  a  v  a2  s .  c  o  m*/
}

From source file:edu.ku.brc.ui.UIRegistry.java

/**
 * Adds Key navigation bindings to a component. (Is this needed?)
 * @param comp the component/*ww w. ja v  a2s. com*/
 */
public void addNavBindings(JComponent comp) {
    InputMap inputMap = comp.getInputMap();

    //Ctrl-b to go backward one character
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_B, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    inputMap.put(key, DefaultEditorKit.backwardAction);

    //Ctrl-f to go forward one character
    key = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    inputMap.put(key, DefaultEditorKit.forwardAction);

    //Ctrl-p to go up one line
    key = KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    inputMap.put(key, DefaultEditorKit.upAction);

    //Ctrl-n to go down one line
    key = KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
    inputMap.put(key, DefaultEditorKit.downAction);
}