我正在使用多个窗口开发 ScalaFX 应用程序。但是,如果我在另一个窗口正在打开的过程中拖动一个 ScalaFX 窗口,整个桌面就会变得无响应。发生这种情况时,大多数应用程序根本不响应鼠标事件,并且不可能关闭任何一个 ScalaFX 窗口。我发现恢复响应的唯一方法是通过任务管理器终止 Java 进程,它本身只能在发出 ctrl-alt-del 后打开。
这是一个可以触发问题的简单脚本。它加载一个窗口,等待 3 秒,然后打开第二个窗口。但是,如果在打开第二个窗口的同时拖动第一个窗口,则会触发该问题。
import javafx.embed.swing.JFXPanel
import scalafx.application.Platform
import scalafx.scene.Scene
import scalafx.scene.control.Label
import scalafx.stage.Stage
new JFXPanel
Platform.runLater {
val stage = new Stage {
title = "Stage 1"
width = 300
height = 200
scene = new Scene {
root = new Label("Stage 1")
}
}
stage.showAndWait()
}
Thread sleep 3000
Platform.runLater {
val stage = new Stage {
title = "Stage 2"
width = 300
height = 200
scene = new Scene {
root = new Label("Stage 2")
}
}
stage.showAndWait()
}
我在 Windows 10 机器上使用 Java 8 update 60 和 Scalafx 8.0.40-R8。
关于为什么会发生这种情况或如何解决它的任何想法?