Christopher Carpenter
Christopher Carpenter

Reputation: 21

JavaFX equivalent to java.awt.EventQueue

Does JavaFX contain an equivalent to java.awt.EventQueue? For my application I need to intercept all GUI related events such as mouse and keyboard input, and so far I haven't been able to find a way to do it without attaching listeners to every GUI element.

Upvotes: 2

Views: 1373

Answers (1)

James_D
James_D

Reputation: 209408

This isn't quite the same as the question in your title, but to intercept all events, you can add an EventFilter to the Scene:

scene.addEventFilter(Event.ANY, new EventHandler<Event>() {
        @Override
        public void handle(Event event) {
            System.out.println(event);
        }
});

If you need to veto the event, call event.consume()

Upvotes: 6

Related Questions