I am using Fade transitions as Parallel Transition's child in my project. I changed button's opacity for my business logic 1 to 0. When I changed a irrelevant ToggleButtons' (which is not child of fade or parallel transition)style by using setStyle() method, irrelevant ToggleButton's opacity changes, I think its with the transition's time frame but I can't work it out.
Buttons are painted red with this code.
try {
if (thePane.getChildren() != null) {
for (Node node : thePane.getChildren()) {
if (node instanceof GridPane) {
ObservableList<Node> nodes = ((GridPane) node).getChildren();
for (Node node1 : nodes) {
if (node1 instanceof ToggleButton) {
ToggleButton toggle= ((ToggleButton) node1);
if (toggle!= null) {
if (toggle.getId().equals(id)) {
if (toggle.isSelected()) {
toggle.styleProperty().setValue("-fx-background-color: #ff0000,linear-gradient(#a81010 0%, #ba2525 20%, #ea2525 100%),linear-gradient(#a81010, #ea2525),radial-gradient(center 50% 0%, radius 100%, rgba(214,21,21,0.9), rgba(255,255,255,0));");
} else {
toggle.styleProperty().setValue("-fx-background-color: #a50000,linear-gradient(#870909 0%, #c93434 20%, #a00303 100%), linear-gradient(#870909, #a00303), radial-gradient(center 50% 0%, radius 100%, rgba(148,114,114,0.9), rgba(255,255,255,0));");
}
}
}
}
}
}
}
}
}
And adding some buttons to FadeTransition as child of Paralleltransition to make flash, with this lines.
try{
ToggleButton toggle= getToggleButton();
FadeTransition fadeTransition = new FadeTransition(Duration.seconds(0.9), toggle);
fadeTransition.setNode(toggle);
fadeTransition.setFromValue(10.0);
fadeTransition.setToValue(0.0);
fadeTransition.setCycleCount(Animation.INDEFINITE);
if (fadeTransitionList.get(toggle.getId()) == null) {
parallelTransition.stop();
parallelTransition.getChildren().add(fadeTransition);
parallelTransition.play();
fadeTransitionList.put(toggle.getId(), fadeTransition);
}
} catch (Exception e){
e.printStackTrace();
}
As i said, irrelevant buttons (which has not been added to ParallelTransition (also FadeTransition)'s) opacity changes.
I think Fade Transition in JavaFX runs for a region in the screen, and the region affects unrelated buttons
Any help would be appreciated.