I wrote a GUI in ScalaFX whichs works quite well when testing it isolated. Things to mention:
The whole startup procedure looks like this:
def main(args: Array[String]) {
...
...
JFXGui.setData(data)
JFXGui.main(Array())
}
The problem:
setData
is really just a simple setter method. The idea is that JFXGui
should draw the data as soon as possible after JFXGui.main
was called. But: how can I realize this inside of JFXGui
? Is there something like an "onready"-method?JFXGui.main
is blocking forever, therefore the call to the setter is unreachable code.How could I fix this? any help is appreciated, thanks.
edit:
JFXGui
is the name of my ScalaFX UI:
object JFXGui extends JFXApp {
private var data: Data = _
def setData(data: Data) {
this.data = data;
}
// tons of ScalaFX related things which visualize the data object
// ...
}
The Gui
object no longer should be an object, but a class with constructor parameters.
class Gui(data: Data) extends JFXApp {
//your existing code without the field data and the method setData()
}
In the startup class:
new Gui(data).main(Array())
You do not necessarily have to use JFXApp
in order to run your application. I suggest you having a look at the source code of JFXApp.main()
and the class AppHelper
. They contain ~10 lines of code combined so you can just copy their source code and tailor it to your needs.