Hi, community and david_bernard_31! Thanx for supporting cool JFX project, but i have trouble while using it.
com.jme3x.jfx.2.184.2016-04-30_145140-ccbd413
It happens when i just changing HBox panel. I mean i removing all children of panel and then adding new ones.
Better look code ithink:
FxPlatformExecutor.runOnFxApplication(() -> {
controller.orderPanel.getChildren().clear();
for (Unit unit : battleManager.getUnits()) {
if (unit.isAlive()) {
ImageView imageView = new ImageView(getClass().getResource("/png/" + unit.getImageName()).toExternalForm());
imageView.setFitWidth(32);
imageView.setPreserveRatio(true);
imageView.setEffect(new SepiaTone(0.9));
controller.orderPanel.getChildren().add(imageView);
controller.orderPanel.requestLayout();
}
}
});
U can ignore unit and controller entities, it doesn’t matter at all. This code simply clear orderPanel(HBox), creating ImageView and add it into panel. Dat’s it! Sometimes it is going ok, but sometimes image views r just sit on top each other like if panel wasn’t Hbox. It is very strange bug. As i suspect it happens cause of i’m changing GUI dynamically and sometimes it happens not in JavaFX thread (even code wrapped in FxPlatformExecutor.runOnFxApplication). Am i right? Can anyone give me advice about how to solve this? Any help appreciated
if you do anything outside of javafx thread, it is simply false and anything might happen.
Anyway does the same bug also happen with plain jfx outside of jme?
Because the ui binding does not change the rendering logic at all, it just grabs a screenshot (simplified) converts to texture and displays in jme. All layouting logic is unchanged.
Hi, thx for reply. As i know JFX FxPlatformExecutor.runOnFxApplication() should guarantee than code inside it will execute in JavaFX thread. What u mean “plain jfx outside of jme”?
The problem appears periodically, not every use case, dat’s strange. I suspected MAYBE code executed not in JavaFX thread, but if we look inside library we will see
Empire_Phoenix, as i know u created a game using JavaFX, right? U probably used some dynamic gui content, do u? If u did, have u any thread issues like i have and how u solve them?
We use com.sun.javafx.application.PlatformImpl.runLater(Runnable r) from a normal AppState.update(float tpf) method to update dynamic content for Skylimit Tycoon, but we keep track of tpf so we only update 25 times per second.
Updating to often should not cause any problems, (except maybee performance)
Yes, I suspect a multithreading error, or alternativly you found a layout bug in javafx
Thank u, guys! I finally found bug in my code, when i forgot wrap code runLater. Now seems like all works just fine, need more tests. I even will try to omit tonegod now(unfort this cool library not supported since 2014 as i know) and do all stuff on JavaFX. If u r interested i can share results of this experiment later
Ok, now i can post some results here.
Maybe just simpe image will be enough for the first time.
I know this image looks quite poorly(no real models, effects and stuff) but for now we just talking about possibility of using only JavaFX as GUI. And it looks like it is possible at this stage of my development. Hope this helps someone.