I have a large amount of nodes and currently using fade trasition code below,
ft1 = new FadeTransition(Duration.millis(500), hBox_outter_last);
ft1.setFromValue(1.0);
ft1.setToValue(0.3);
ft1.setCycleCount(Animation.INDEFINITE);
ft1.setAutoReverse(true);
ft1.play();
however this is CPU consuming and was told that I can use the following, however this does not work, anyone can help with this
DoubleProperty opacity = new SimpleDoubleProperty();
Transition opacityTransition = new Transition() {
protected void interpolate(double frac) {
opacity.set(frac);
}
};
// elsewhere
hBox_outter_last.opacityProperty().bind(opacity);
You also need to set the cycleDuration
(and I assume you are calling play()
somewhere...):
Transition opacityTransition = new Transition() {
{
setCycleDuration(Duration.seconds(1));
}
protected void interpolate(double frac) {
opacity.set(frac);
}
};
If that doesn't fix it, please post an MCVE