【发布时间】:2017-08-08 11:53:03
【问题描述】:
我正试图让我的窗口专注于按键(使用 jnativehook),但收到此错误:
java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = JNativeHook Dispatch Thread` exception.
似乎我无法从钩子的线程中更改 UI。
有什么方法可以让舞台出现在前台?如有必要,我愿意使用其他关键挂钩。
【问题讨论】:
-
只需将电话转入
Platform.runLater(...)。在此论坛中搜索“java.lang.IllegalStateException: not on FX Application Thread”。 -
谢谢! runLater 示例之一正在工作,它更新标签的文本。但是调用primaryStage.toFront();时,主窗口仍然在后台;
标签: java multithreading javafx-2 javafx-8 jnativehook