List of usage examples for javafx.scene.input InputEvent getEventType
@Override public EventType<? extends InputEvent> getEventType()
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250); TextField textBox = new TextField(); textBox.setPromptText("Write here"); // Define an event handler EventHandler handler = new EventHandler<InputEvent>() { public void handle(InputEvent event) { System.out.println("Handling event " + event.getEventType()); event.consume();/*w w w . j av a2 s.c o m*/ } }; scene.addEventHandler(DragEvent.DRAG_EXITED, handler); scene.addEventHandler(MouseEvent.MOUSE_DRAGGED, handler); root.getChildren().add(textBox); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250); TextField textBox = new TextField(); textBox.setPromptText("Write here"); // Define an event filter EventHandler filter = new EventHandler<InputEvent>() { public void handle(InputEvent event) { System.out.println("Filtering out event " + event.getEventType()); event.consume();/* w w w . java 2 s. c om*/ } }; // Register the same filter for two different nodes scene.addEventFilter(MouseEvent.MOUSE_PRESSED, filter); // Register the filter for another event type scene.addEventFilter(KeyEvent.KEY_PRESSED, filter); root.getChildren().add(textBox); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { Group root = new Group(); Scene scene = new Scene(root, 300, 250); TextField textBox = new TextField(); textBox.setPromptText("Write here"); // Define an event filter EventHandler filter = new EventHandler<InputEvent>() { public void handle(InputEvent event) { System.out.println("Filtering out event " + event.getEventType()); event.consume();//from w w w . j a v a2 s .co m } }; // Register the same filter for two different nodes scene.addEventFilter(MouseEvent.MOUSE_PRESSED, filter); // Register the filter for another event type scene.addEventFilter(KeyEvent.KEY_PRESSED, filter); scene.removeEventFilter(MouseEvent.MOUSE_PRESSED, filter); root.getChildren().add(textBox); primaryStage.setScene(scene); primaryStage.show(); }