I am using scene snapshot method in order to get image of scene each time when appropriate style sheet is applied to scene. This I do before scene is shown and than I make a gif of snapshot. It works fine except for styling of some elements like .combobox .arrow.
For example if I change style of combobox border it will be visible in snapshot immediately but for arrow it will not be visible. In runtime, when application runs style is applied well.
Here is part of code for illustration:
URL url = cssFile.toURI().toURL();
WritableImage image = null;
scene.getStylesheets().add(url.toString());
image = scene.snapshot(null);
File fileA = new File("snapshot.png");
try {
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", fileA);
}
catch (Exception s) {
}
Imagine we have scene with combobox in the scene. If I apply next style to combobox:
.ComboBox_Example_Style {
-fx-opacity: 1;
-fx-effect: none;
-fx-padding: 0 5 0 5;
-fx-border-color: yellow;
-fx-border-width: 3;
-fx-border-radius: 10;
-fx-border-insets: 2;
}
.ComboBox_Example_Style .arrow {
-fx-background-color: green;
}
.ComboBox_Example_Style .arrow-button {
-fx-background-color: blue;
}
Then in snapshot.png border and arrow-button will be in colored as in css but arrow style will not.
When stage is shown than all styles for combo are correct.
For example if I change style of combobox border it will be visible in snapshot immediately but for arrow it will not be visible. In runtime, when application runs style is applied well.
Here is part of code for illustration:
URL url = cssFile.toURI().toURL();
WritableImage image = null;
scene.getStylesheets().add(url.toString());
image = scene.snapshot(null);
File fileA = new File("snapshot.png");
try {
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", fileA);
}
catch (Exception s) {
}
Imagine we have scene with combobox in the scene. If I apply next style to combobox:
.ComboBox_Example_Style {
-fx-opacity: 1;
-fx-effect: none;
-fx-padding: 0 5 0 5;
-fx-border-color: yellow;
-fx-border-width: 3;
-fx-border-radius: 10;
-fx-border-insets: 2;
}
.ComboBox_Example_Style .arrow {
-fx-background-color: green;
}
.ComboBox_Example_Style .arrow-button {
-fx-background-color: blue;
}
Then in snapshot.png border and arrow-button will be in colored as in css but arrow style will not.
When stage is shown than all styles for combo are correct.