I would like to open my main application window as slowly appearing. So I was trying to use Timeline to change stage's opacityProperty:
timeline.getKeyFrames().addAll
(
new KeyFrame( Duration.ZERO, new KeyValue( stage.opacityProperty(), 0.1 ) ),
new KeyFrame( new Duration( 1000 ), new KeyValue( stage.opacityProperty(), 1.0 ) )
);
stage.show();
timeline.play();
Unfortunately, there is no animation at all. I see window with start opacity value (0.1). On the other hand the actual opacity was changing and is 1.0. I can see it if force window redrawing. For example, by move mouse over the window. Looks like there is no stage repainting after changing stage.opacityProperty.
To make sure I was trying to change window's height also. Something like this:
timeline.getKeyFrames().addAll
(
new KeyFrame( Duration.ZERO, new KeyValue( stage.opacityProperty(), 0.0 ), new KeyValue( stage.heightProperty(), 0 ) ),
new KeyFrame( new Duration( 1000 ), new KeyValue( stage.opacityProperty(), 1.0 ), new KeyValue( stage.heightProperty(), 700 ) )
);
This time it works fine. Both properties visually grows (height and opacity).
timeline.getKeyFrames().addAll
(
new KeyFrame( Duration.ZERO, new KeyValue( stage.opacityProperty(), 0.1 ) ),
new KeyFrame( new Duration( 1000 ), new KeyValue( stage.opacityProperty(), 1.0 ) )
);
stage.show();
timeline.play();
Unfortunately, there is no animation at all. I see window with start opacity value (0.1). On the other hand the actual opacity was changing and is 1.0. I can see it if force window redrawing. For example, by move mouse over the window. Looks like there is no stage repainting after changing stage.opacityProperty.
To make sure I was trying to change window's height also. Something like this:
timeline.getKeyFrames().addAll
(
new KeyFrame( Duration.ZERO, new KeyValue( stage.opacityProperty(), 0.0 ), new KeyValue( stage.heightProperty(), 0 ) ),
new KeyFrame( new Duration( 1000 ), new KeyValue( stage.opacityProperty(), 1.0 ), new KeyValue( stage.heightProperty(), 700 ) )
);
This time it works fine. Both properties visually grows (height and opacity).
- duplicates
-
JDK-8092737 Scene not repainted on change to Stage opacity with StageStyle.TRANSPARENT
-
- Resolved
-