I'm struggling to what code I should present here, because it is very complicated and it is working at the same time.
The thing is that I build a relatively complicated JavaFX sceengraph and update the content of a VBox with it from a Scala application.
Now, when I run the application using sbt run, with the console window, the sceneragph loads quickly. When I run it from the packaged .jar ( I use sbt-one-jar for this ) the sceenraph takes ages to load.
So everything is working, everything works the same way, except that running from the .jar magically slows it down.
Anyway I paste some code, even if it is not very enlightening:
def SetVboxSceneGraph(
id:String,
blob:String,
handler:(MyEvent)=>Unit
)
{
val comp=MyComponent.FromBlob(blob,handler)
comp.CreateNode
val box=GetMyBox(id)
val vbox=box.GetNode.asInstanceOf[VBox]
vbox.getChildren().clear()
vbox.getChildren().add(comp.GetParent)
}
Edit:
According to sillyfly's suggestion I measured the times each step takes in updating the scenegraph. The steps that slows down is:
comp.CreateNode
This is the part responsible for building the JavaFX scenegraph from an XML markup ( passed as "blob" ) which I developed to describe so called "MyComponent"s which are classes that build custom widgets from existing JavaFX widgets. Once the scenegraph is built the updating takes the same amount of time.