I´m starting with JavaFX and got stucked on a performace problem. I´ll try to explain instead of paste the code because it´s too long and not centralized.
I started my Application, invoke the launch method and received the Stage object. Until now, that´s all OK.
Now I start to create my structure with Groups. I created my first Group (lets call it ‘A’) and set it with setRoot() on the Stage. Then create 3 other groups (each with a complex structure of leafs) and add each one as child of the first Group (the one we call ‘A’).
The problem: I´d like to update just one of Group structure, without doing all of them and call setRoot() again on Stage object.
– But if I try to remove it from the parent I got a exception “java.lang.IllegalStateException: Not on FX application thread;”.
– If I try to put it on another Group, I still get the same exception.
Is there any way I can reuse the group I already made, or just replace the group I need to remake?
I tried to explain at most my problem, but since english is not my natural language I hope u can understand 😉
Thanks in advance…
Not on FX application thread;means you run UI operations on the wrong thread. Modifying UI should happen only on UI thread (aka “FX application thread”), otherwise it would be impossible to synchronize UI operations. To achieve that use next code:where
Platformisjavafx.application.Platform