我刚刚开始在我的 JavaFX 项目中使用 CSS,遇到了一个我无法解决的问题。我有一个用作主菜单的 TreeView,我想摆脱出现的任何焦点/非焦点边框。我设法解决了在与 TreeView(聚焦)交互时出现蓝色边框的问题,完全删除了它,但是每次我与其他东西交互时都会出现这个白色边框。
我曾尝试在网上寻找此问题的解决方案,但找不到任何解决方案。我曾尝试以不同方式更改 CSS 文件,以解决类似的聚焦/不聚焦问题,但都没有奏效。
我的 CSS 文件:
.grid-pane {
-fx-background-color: #181818;
}
.tree-view, .tree-cell {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
#mainMenu .tree-cell {
-fx-padding: 0.25em 0em 0.25em 0em;
-fx-font-size: 28px;
-fx-background-color: #181818;
}
#mainMenu .tree-cell > .tree-disclosure-node > .arrow {
-fx-background-color: #FFFFFF;
-fx-alignment: center;
}
#mainMenu .tree-cell:expanded > .tree-disclosure-node > .arrow {
-fx-background-color: #FFFFFF;
-fx-alignment: center;
}
#mainMenu .label {
-fx-text-fill: white;
}
When focused (desired outcome)
抱歉英语不好,因为它不是我的母语。 感谢您的支持!
答案 0 :(得分:0)
其实我刚刚找到了答案。我仅将 -fx-background-insets: 1;
添加到树视图 css 中,它不再出现。感谢迄今为止所有尝试提供帮助的人!
.tree-view {
-fx-background-insets: 1;
}