Through a listener I intend to change the background image of a TitledPane
although I have not succeeded. When starting the code, the style sheet shows the 'DownArrow.png' but when expanding/collapsing TitledPane
the image the image disappears and nothing is displayed. The images that I use are in the same folder as the code and the style sheet. The code I am using is the following:
titledPane.expandedProperty().addListener((obs, contraído, expandido) -> {
if (expandido) {
titledPane.lookup(".title").setStyle(
"-fx-background-image : url('flechaAbajo.png'); "
);
} else {
titledPane.lookup(".title").setStyle(
"-fx-background-image : url('flechaArriba.png'); "
);
}
});
The style sheet is:
.titled-pane > .title {
-fx-background-image : url('flechaAbajo.png');
-fx-background-repeat: stretch;
-fx-background-position: right;
}
Try with CSS: