我正在开发一个元素,并将 JavaFX 8 用于 GUI。当我单击选项卡 Pane 的选项卡内的文本时,文本周围会出现一个灰色细框,如下图所示。当我点击其他地方时,它消失了。有谁知道如何摆脱这个盒子?最好使用 CSS。
提前致谢。
CSS:
.tab-pane {
-fx-background-insets: 0;
-fx-padding: 0;
}
.tab-pane .headers-region {
-fx-padding: 0;
-fx-background-insets: 0;
}
.tab-header-area {
-fx-padding: 0;
-fx-background-insets: 0;
}
.tab-header-background {
-fx-background-color: #9a3838;
}
.tab {
-fx-background-color: #8b3333;
-fx-padding: 5px 10px 5px 10px;
-fx-background-radius: 0px;
-fx-focus-color: transparent;
-fx-font-size: 14px;
}
.tab:top {
-fx-background-insets: 0;
}
.tab:hover {
-fx-background-color: #b54343;
}
.tab:selected {
-fx-background-color: #c24848;
}
.tab Label {
-fx-text-fill: white;
-fx-focus-color: transparent;
-fx-font-weight: bold;
}
.tab #SearchField {
-fx-background-insets: 0;
}
最佳答案
灰色矩形是一个 Region
样式类 .focus-indicator
,你可以隐藏它:
.tab-pane:focused > .tab-header-area > .headers-region > .tab:selected .focus-indicator {
-fx-border-color: transparent;
}
关于java - 如何摆脱 JavaFX 中的灰色选择边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30642032/