Example usage for javax.swing.text DefaultEditorKit upAction

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

Introduction

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

Prototype

String upAction

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

Click Source Link

Document

Name of the Action for moving the caret logically upward 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:edu.ku.brc.ui.UIRegistry.java

/**
 * Adds Key navigation bindings to a component. (Is this needed?)
 * @param comp the component/* ww  w . j  av  a 2  s  .  c  o  m*/
 */
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);
}