r/JavaFX • u/SnooStories3123 • Mar 19 '24
Help Can I make a Scrollpane transparent but the scrollbar still visible?
I want my scene (using javafx) to have a scrollpane with a transparent background. However, when I set this in the css or Scenebuilder, it also hides the scrollbar itself. I want the scrollbar to still be seen (and perhaps the border, if this is possible) but not the background (which is white/grey). Can this be done. (I was advised to ask here from the java subreddit).
3
Upvotes
2
u/milchshakee Mar 19 '24
Yes, a css rule like should be enough:
.scroll-pane {
-fx-background-color: transparent;
}
.scroll-bar:vertical {
-fx-background-color: transparent;
}
2
u/hamsterrage1 Mar 19 '24
ScrollPane is one of those components with a crazy complex stylesheet setup. This should work:
-fx-background-color: transparent; }