3

I can not set transparent background in scrollpane. Probably because it contains anchorpane, and that anchorpane contains buttons? White background from scrollpane and red from anchorpane:

enter image description here

DanielBarbarian
  • 5,093
  • 12
  • 35
  • 44
ground
  • 76
  • 1
  • 10

2 Answers2

9

You have to use css and like this:


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

and(cause ScrollPane has a Viewport)

.scroll-pane > .viewport {  //not .scrollpane but .scroll-pane
   -fx-background-color: transparent;
}

or

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

If it doesn't work,either you have not defined externall css file well,or you have added some kind of container into the ScrollPane which has also a default background color.

GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93
0

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.

if not Please Refer to this question

JavaFX ScrollPane border and background

Community
  • 1
  • 1
Rahul Singh
  • 19,030
  • 11
  • 64
  • 86