-
Bug
-
Resolution: Not an Issue
-
P4
-
fx2.1.1, fx2.1, 7u6
-
Three diferent computers(Windows 7 64bits) with the same result.
The first one:
>java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)and JavaFx 2.1
the second one: same java version and JavaFX 2.2.0-beta
The third version:
>java -version
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)and JavaFX 2.1.1
Three diferent computers(Windows 7 64bits) with the same result. The first one: >java -version java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing) and JavaFx 2.1 the second one: same java version and JavaFX 2.2.0-beta The third version: >java -version java version "1.6.0_33" Java(TM) SE Runtime Environment (build 1.6.0_33-b03) Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode) and JavaFX 2.1.1
I have a Java swing application with a JFXPanel inside. I have a Jbutton that modifies the value of a javafx object(Scale), like this:
private final Scale sceneScale;
[...]
scenarioGroup = new Group();
scene = new Scene(scenarioGroup, Color.TRANSPARENT);
scenarioGroup.setCacheHint(CacheHint.SPEED);
sceneScale = new Scale(1, 1, 0, 0);
scenarioGroup.getTransforms().add(sceneScale);
[...]
//This method is called from JButton
public void setZoomLevel(final double zoomLevel) {
Platform.runLater(new Runnable() {
@Override
public void run() {
sceneScale.xProperty().set(zoomLevel);
sceneScale.yProperty().set(zoomLevel);
}
});
}
But I have an error.Sometimes the scale wasn't updated/refreshed/repainted until a shape was modified/added/removed/visibilityChange/etc by JavaFX mouse events.
Then I search a lot to find out the problem:
1st I try to add
scenarioGroup.requestLayout();
after
sceneScale.xProperty().set(zoomLevel);
sceneScale.yProperty().set(zoomLevel);
2nd I tryed to force a pulse with that:
Toolkit.getToolkit().requestNextPulse();
So the code was like that:
public void setZoomLevel(final double zoomLevel) {
Platform.runLater(new Runnable() {
@Override
public void run() {
sceneScale.xProperty().set(zoomLevel);
sceneScale.yProperty().set(zoomLevel);
scenarioGroup.requestLayout();
Toolkit.getToolkit().requestNextPulse();
}
});
}
It dint' fix anything and I dint' know what was going on, so I create some listeners of the scene and the stage:
Toolkit.getToolkit().addSceneTkPulseListener(new com.sun.javafx.tk.TKPulseListener() {
@Override
public void pulse() {
System.out.println("SceneTkPulseListener");
}
});
Toolkit.getToolkit().addStageTkPulseListener(new com.sun.javafx.tk.TKPulseListener() {
@Override
public void pulse() {
System.out.println("StageTkPulseListener");
}
});
these listeners sometimes work, but sometimes don't. In fact, with the java 64bit version MOST of the times is perftect. With the 32 version with JavaFX 2.1.1 NEVER works. And with 32 bit and JavaFX 2.2.0-beta SOMETIMES.
I also tried to modify the cache hints, so I added: "scenarioGroup.setCacheHint(CacheHint.SPEED);" with the same result.
:|
Thank you very much and congratulations, JavaFX is impressive.
private final Scale sceneScale;
[...]
scenarioGroup = new Group();
scene = new Scene(scenarioGroup, Color.TRANSPARENT);
scenarioGroup.setCacheHint(CacheHint.SPEED);
sceneScale = new Scale(1, 1, 0, 0);
scenarioGroup.getTransforms().add(sceneScale);
[...]
//This method is called from JButton
public void setZoomLevel(final double zoomLevel) {
Platform.runLater(new Runnable() {
@Override
public void run() {
sceneScale.xProperty().set(zoomLevel);
sceneScale.yProperty().set(zoomLevel);
}
});
}
But I have an error.Sometimes the scale wasn't updated/refreshed/repainted until a shape was modified/added/removed/visibilityChange/etc by JavaFX mouse events.
Then I search a lot to find out the problem:
1st I try to add
scenarioGroup.requestLayout();
after
sceneScale.xProperty().set(zoomLevel);
sceneScale.yProperty().set(zoomLevel);
2nd I tryed to force a pulse with that:
Toolkit.getToolkit().requestNextPulse();
So the code was like that:
public void setZoomLevel(final double zoomLevel) {
Platform.runLater(new Runnable() {
@Override
public void run() {
sceneScale.xProperty().set(zoomLevel);
sceneScale.yProperty().set(zoomLevel);
scenarioGroup.requestLayout();
Toolkit.getToolkit().requestNextPulse();
}
});
}
It dint' fix anything and I dint' know what was going on, so I create some listeners of the scene and the stage:
Toolkit.getToolkit().addSceneTkPulseListener(new com.sun.javafx.tk.TKPulseListener() {
@Override
public void pulse() {
System.out.println("SceneTkPulseListener");
}
});
Toolkit.getToolkit().addStageTkPulseListener(new com.sun.javafx.tk.TKPulseListener() {
@Override
public void pulse() {
System.out.println("StageTkPulseListener");
}
});
these listeners sometimes work, but sometimes don't. In fact, with the java 64bit version MOST of the times is perftect. With the 32 version with JavaFX 2.1.1 NEVER works. And with 32 bit and JavaFX 2.2.0-beta SOMETIMES.
I also tried to modify the cache hints, so I added: "scenarioGroup.setCacheHint(CacheHint.SPEED);" with the same result.
:|
Thank you very much and congratulations, JavaFX is impressive.