Nun*_*ong 12 scrollpane javafx-2
我在ScrollPane的默认背景和边框方面遇到了一些问题.使用这种风格使问题更加清晰.
setStyle("-fx-background-color:blue; -fx-border-color:crimson;");
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这种风格并且没有运气,只有红色的边框消失了,并留下了我的蓝色边框.
setStyle("-fx-background-color:blue; -fx-background-insets:0; -fx-border-color:crimson; -fx-border-width:0; -fx-border-insets:0;");
Run Code Online (Sandbox Code Playgroud)

我看过这个旧帖子JavaFX Hide ScrollPane灰色边框和http://docs.oracle.com/javafx/2/ui_controls/editor.htm
这行代码既不起作用也不起作用
scrollPane.getStyleClass().add("noborder-scroll-pane");
Run Code Online (Sandbox Code Playgroud)
谢谢
Mik*_*arn 25
在当前版本的JavaFX 8中,您可以使用边对边样式类来完全删除边框:
<ScrollPane styleClass="edge-to-edge"/>
Run Code Online (Sandbox Code Playgroud)
Nun*_*ong 18
我找到了一个解决方案,并希望将其发布在这里,以便其他人不必浪费时间再找到它.
通过查看使用此命令从库中提取的JavaFx(caspian.css)的默认css.
jar xf jfxrt.jar com/sun/javafx/scene/control/skin/caspian/caspian.css
Run Code Online (Sandbox Code Playgroud)
我可以看到我错过的那个
-fx-padding: 0;
Run Code Online (Sandbox Code Playgroud)
所以这是我正在使用的css类.
.scroll-pane {
-fx-background-insets: 0;
-fx-padding: 0;
}
.scroll-pane:focused {
-fx-background-insets: 0;
}
.scroll-pane .corner {
-fx-background-insets: 0;
}
Run Code Online (Sandbox Code Playgroud)
小智 9
首先尝试使用它
.scroll-pane > .viewport {
-fx-background-color: transparent;
}
Run Code Online (Sandbox Code Playgroud)
在设置背景颜色之前
小智 8
似乎有一个简单的解决方案,即使用"-fx-background:rgb(80,80,80);",即
scrollPane.setStyle("-fx-background: rgb(80,80,80);");
Run Code Online (Sandbox Code Playgroud)
至少这对我来说非常合适,而"-fx-background-color:rgb(80,80,80);" 或"-fx-control-inner-background:rgb(80,80,80);" 在javafx 8中不起作用." - fx-background-color:rgb(80,80,80);" 在早期版本的javafx中工作过.