Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollPanes in JavaFX 8 always have gray background

When I upgraded by JavaFX app from JavaFX 2 to JavaFX 8, I noticed that ScrollPanes always showed up as gray rectangles, even with a background color set or the background set to be transparent.

like image 517
Jon Onstott Avatar asked Apr 09 '14 03:04

Jon Onstott


People also ask

How to set background color of ScrollPane in JavaFX?

To alter borders, you would have to use "fx-background-color" . To modify the viewport's background color, you should modify the "fx-background" attribute.

How do you make a Scrollpane transparent?

Set an id to your AnchorPane in the fxml and then in your css assign the id to -fx-background-color : transparent. Hope this works.


2 Answers

I found the solution in this discussion: https://community.oracle.com/thread/3538169

First I needed this:

.scroll-pane > .viewport {    -fx-background-color: transparent; } 

Then I could set the background color to whatever I like. In this case, I'm making all ScrollPane backgrounds transparent:

.scroll-pane {    -fx-background-color: transparent; } 
like image 149
Jon Onstott Avatar answered Oct 02 '22 17:10

Jon Onstott


Came acroos this just now, it's not working with -fx-background-color, but it is with -fx-background

.scroll-pane {    -fx-background: #FFFFFF;    -fx-border-color: #FFFFFF; } 
like image 36
user3190916 Avatar answered Oct 02 '22 17:10

user3190916