'JavaFX Hide ScrollPane gray border

Is there any way of hiding the gray border of an ScrollPane control in JavaFX ?



Solution 1:[1]

Or in CSS

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

Solution 2:[2]

In pure Java, without CSS, you need to set the background like this, which is a lot more verbose than the CSS approach.

ScrollPane scrollPane = new ScrollPane();
scrollPane.setBackground(
  new Background(new BackgroundFill(Color.TRANSPARENT, null, null))
);

Solution 3:[3]

Making the border transparent will leave a 1 pixel gap around the edge. IMHO, the correct answer is the one that Jens Piegsa linked to. https://stackoverflow.com/a/17540428/1725096

Solution 4:[4]

If you really want to blow away any pre-defined styles applied you can use:

ScrollPane scrollPane = new ScrollPane();    
scrollPane.getStyleClass().clear();

This also works for any sub-type of Node

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andreas
Solution 2 sk22
Solution 3 Community
Solution 4 Aetherial