ground
ground

Reputation: 116

JavaFX ScrollPane how set transparent background

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

Upvotes: 7

Views: 9077

Answers (2)

GOXR3PLUS
GOXR3PLUS

Reputation: 7255

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.

Upvotes: 13

Rahul Singh
Rahul Singh

Reputation: 19622

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

Upvotes: 0

Related Questions