我想使用此代码从我的程序中显示通用 Javafx 场景
class JFXWindowDisplay(myScene:Scene) extends Application {
def start( stage: Stage) {
stage.setTitle("My JavaFX Application")
stage.setScene(myScene)
stage.show()
}
}
//OBJECT NEEDED TO RUN JAVAFX : http://stackoverflow.com/questions/12124657/getting-started-on-scala-javafx-desktop-application-development
object JFXWindowDisplay extends App {
override def main(args: Array[String]) {
Application.launch(classOf[JFXWindowDisplay], args: _*)
}
}
如何将 Scene 参数传递给 compagnon 对象?
例如,我想创建一个程序,从 scala 脚本执行中打开一个新的 javafx 窗口:
class myProgram() extends App {
val root = new StackPane
root.getChildren.add(new Label("Hello world!"))
val myScene = new Scene(root, 300, 300))
// then run ControlTest object with this scene
ControlTest(myScene)
}