I want to change the background color of a ScrollPane. This is part of my code where I try to do that:
val sp=new javafx.scene.control.ScrollPane(new Group(new Text(...)))
sp.setPannable(true)
sp.setStyle("-fx-background-color: blue")
sp.setBackground(new Background(Array(new BackgroundFill(Color.DARKCYAN,new CornerRadii(0),Insets(0)))))
Text appears OK, but both attempts to change the background color have no effect, using:
Scala version 2.10.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_05).
Inspecting with Scenic View, I discover that two StackPanes have unexpectedly appeared in the scene graph below the ScrollPane, so the hierarchy is:
If I change the background of either of the StackPane-s to, say, "-fx-background-color: blue"
(with Scenic View), it has effect, but not the style of the ScrollPane. But how to do that from code? If I do
println(sp.content())
, it says
Group@567fa81a
Is there a simple way to access the StackPanes or change the background? I could "slap in" a big filled rectangle, but that seems ugly and complicates resizing, what is wrong with the background proper?
sp.setStyle("-fx-background: blue")
instead of:
sp.setStyle("-fx-background-color: blue")