Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX Hide ScrollPane gray border

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

like image 835
nailujed Avatar asked Oct 15 '12 16:10

nailujed


3 Answers

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;");
like image 88
Sergey Grinev Avatar answered Nov 14 '22 06:11

Sergey Grinev


Or in CSS

.scroll-pane {
    -fx-background-color:transparent;
}
like image 11
Andreas Avatar answered Nov 14 '22 05:11

Andreas


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))
);
like image 5
sk22 Avatar answered Nov 14 '22 05:11

sk22