Example usage for javafx.scene.input KeyEvent getCharacter

List of usage examples for javafx.scene.input KeyEvent getCharacter

Introduction

In this page you can find the example usage for javafx.scene.input KeyEvent getCharacter.

Prototype

public final String getCharacter() 

Source Link

Document

The Unicode character or sequence of characters associated with the key typed event.

Usage

From source file:Main.java

public static java.awt.event.KeyEvent toAwt(final KeyEvent event) {
    final EventType type = event.getEventType();
    if (null == type) {
        return null;
    }/*from  www.  j  a  va2 s.c  om*/

    final int id;
    if (KeyEvent.KEY_TYPED.equals(type)) {
        id = java.awt.event.KeyEvent.KEY_TYPED;
    } else if (KeyEvent.KEY_PRESSED.equals(type)) {
        id = java.awt.event.KeyEvent.KEY_PRESSED;
    } else if (KeyEvent.KEY_RELEASED.equals(type)) {
        id = java.awt.event.KeyEvent.KEY_RELEASED;
    } else {
        return null;
    }

    final long when = -1;
    final int modifiers = modifiers(event);
    final int keyCode = keyCode(event);
    final String keyValue = event.getCharacter();
    final char keyChar = keyValue != null && !keyValue.isEmpty() ? keyValue.charAt(0) : ' ';
    return new java.awt.event.KeyEvent(empty, id, when, modifiers, keyCode, keyChar);
}

From source file:de.serverfrog.pw.ui.MainViewController.java

/**
 *
 * @param event event//from  w w  w . ja va2  s  . c o  m
 */
@FXML
public void onPasswordLengthKeyTyped(KeyEvent event) {
    if (!StringUtils.isNumeric(event.getCharacter())) {
        event.consume();
    }

}

From source file:com.hengyi.japp.print.client.controller.MdController.java

@FXML
private void autoCompleteSapMara(KeyEvent ev) {
    try {/*w  w w  .  j  a  va  2  s  .c o m*/
        if (KeyCode.RIGHT.equals(ev.getCode())) {
            List<SapMara> sapMaras = md.getSapT001().autoCompleteSapMara(matnrField.getText());
            sapMaraListView.setItems(observableArrayList(sapMaras));
            sapMaraListView.setVisible(true);
            sapMaraListView.getSelectionModel().selectFirst();
        } else if (KeyCode.UP.equals(ev.getCode()) || KeyCode.DOWN.equals(ev.getCode())) {
            sapMaraListView.fireEvent(new KeyEvent(null, sapMaraListView, KeyEvent.KEY_PRESSED,
                    ev.getCharacter(), ev.getText(), ev.getCode(), false, false, false, false));
        } else if (KeyCode.ENTER.equals(ev.getCode())) {
            selectSapMara(sapMaraListView.getSelectionModel().getSelectedItem());
            sapMaraListView.setVisible(false);
        }
    } catch (Exception ex) {
        Util.alertDialog(ex);
    }
}

From source file:org.apache.cayenne.modeler.layout.SplashLayout.java

public void onKeyTyped(final KeyEvent event) {
    if (event.getCharacter().equals("\r"))
        openSelectedModel();/* w w  w.j av a2 s .c  o  m*/
}

From source file:org.cryptomator.ui.controllers.SettingsController.java

private void filterNumericKeyEvents(KeyEvent t) {
    if (t.getCharacter() == null || t.getCharacter().length() == 0) {
        return;/*from  www .  j  av a  2 s  .  c  o  m*/
    }
    char c = CharUtils.toChar(t.getCharacter());
    if (!(CharUtils.isAsciiNumeric(c) || c == '_')) {
        t.consume();
    }
}

From source file:org.cryptomator.ui.controllers.UnlockController.java

private void filterAlphanumericKeyEvents(KeyEvent t) {
    if (t.getCharacter() == null || t.getCharacter().length() == 0) {
        return;/*from w w  w  .  j a  v a2s  . c om*/
    }
    char c = CharUtils.toChar(t.getCharacter());
    if (!(CharUtils.isAsciiAlphanumeric(c) || c == '_')) {
        t.consume();
    }
}

From source file:org.cryptomator.ui.InitializeController.java

public void filterAlphanumericKeyEvents(KeyEvent t) {
    if (t.getCharacter() == null || t.getCharacter().length() == 0) {
        return;//from  w  w w. ja v a 2s.  co  m
    }
    char c = t.getCharacter().charAt(0);
    if (!CharUtils.isAsciiAlphanumeric(c)) {
        t.consume();
    }
}