Is there any way of hiding the gray border of an ScrollPane control in JavaFX ?
All controls in JavaFX can be modified using CSS styling. You may want to take a look at reference or tutorial.
Gray ScrollPane's border is actually the only part of the background which is visible behind the content. So you can change it by modifying the background:
ScrollPane sp = new ScrollPane();
sp.setStyle("-fx-background-color:transparent;");
Or in CSS
.scroll-pane {
-fx-background-color:transparent;
}
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))
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With