java - 如何摆脱 JavaFX 中的灰色选择边框

标签 java css javafx javafx-8

我正在开发一个元素,并将 JavaFX 8 用于 GUI。当我单击选项卡 Pane 的选项卡内的文本时,文本周围会出现一个灰色细框,如下图所示。当我点击其他地方时,它消失了。有谁知道如何摆脱这个盒子?最好使用 CSS。

提前致谢。

enter image description here

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/

相关文章:

php - 使用 smarty 编译 product.tpl 时出错

java - 从 C 移植到 Java 需要付出努力

java - 从url中取出参数

java - 重复main方法

java - 使用 stylename 编辑列

资源管理器中的 CSS 中断

java - 将 Shape 从 awt 转换为 javafx 中的 Shape

java - 如何在javaFX中扩展 Accordion 的多个TitledPane?

java - JavaFX 中 ComboBox 的动态填充

java - Spring Security 的渗透测试