As discussed on the mailing list in thread "JFXPanel ignores size change of root node" the following is a workaround to force a JFXPanel to resize itself when the scene's size has changed:
Scene scene = getScene();
setScene(null);
setScene(scene);
invalidate();
In the attached testcase this seems to work for about 70-90% of all attempts. Adding a sleep between setScene(scene) and invalidate makes it 100%. On my core i5 with 2.6 Ghz the 10ms sleep is enough while 9ms is not. YMMV.
Scene scene = getScene();
setScene(null);
setScene(scene);
invalidate();
In the attached testcase this seems to work for about 70-90% of all attempts. Adding a sleep between setScene(scene) and invalidate makes it 100%. On my core i5 with 2.6 Ghz the 10ms sleep is enough while 9ms is not. YMMV.