List of usage examples for javafx.scene.input InputEvent consume
public void consume()
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(); }//from ww w .j a va 2 s.c om }; 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(); }//from w w w .j a v a 2s .c o 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); 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 va 2 s .c o 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(); }