JavaFX equivalent to java.awt.EventQueue

前端 未结 1 1818
余生分开走
余生分开走 2021-01-23 03:37

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 b

相关标签:
1条回答
  • 2021-01-23 04:25

    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()

    0 讨论(0)
提交回复
热议问题