TextField tx = new TextField(); tx.addEventFilter(KeyEvent.KEY_TYPED, maxLength(3));
textField.addEventFilter(KeyEvent.ANY, handler); textField.addEventFilter(KeyEvent.ANY, e -> System.out.println(e));
textField.addEventFilter(KeyEvent.KEY_PRESSED, handler);
public class main extends Application { @Override public void start(Stage primaryStage) { HBox root = new HBox(); TextField textField = new TextField(); textField.addEventFilter(KeyEvent.KEY_PRESSED, e -> { //event filter first catch the event if(e.getCode().equals(KeyCode.UP)){ textField.end(); e.consume(); // this stop propagating the event } }); root.getChildren().add(textField); Scene scene = new Scene(root, 300, 300); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); }
textField.setTextFormatter(textFormatter); textField.addEventFilter(KeyEvent.KEY_RELEASED, e -> { if (e.getCode() == KeyCode.ESCAPE) { cancelEdit();
textField.addEventFilter(KeyEvent.KEY_PRESSED, e -> { if (e.getCode() == KeyCode.ESCAPE) { cancelEdit();
@Override public void start(Stage stage) { final TextField textField = new TextField("Phone: "); textField.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent keyEvent) {
textField2.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent t) {
textField.addEventFilter(KeyEvent.KEY_PRESSED, e -> { if (e.getCode() == KeyCode.ESCAPE) { cancelEdit();
commitEdit(getItem()); }); textField.addEventFilter(KeyEvent.KEY_RELEASED, e -> { if (e.getCode() == KeyCode.ESCAPE) { cancelEdit();
textField.addEventFilter(KeyEvent.KEY_RELEASED, (KeyEvent t) -> { if (t.getCode() == KeyCode.DELETE) {