css - 选择时更改背景颜色表视图,突出显示持久
问题描述
我想在选择tableView(javafx)时更改它的背景颜色,但我有一条蓝色的小线(与突出显示的颜色相同)出现:示例
这是我的 CSS 代码:
.table-view {
-fx-faint-focus-color: transparent;
-fx-focus-color: transparent;
}
.table-view .table-row-cell:selected {
-fx-body-color: #CEDAE3;
-fx-background-color: #CEDAE3;
-fx-text-fill: black;
}
.table-view:focused {
-fx-background-color: transparent,-fx-box-border,-fx-control-inner-background;
}
你能帮助我吗?
解决方案
默认样式表modena.css
, 有一个规则
.table-view:focused > .virtual-flow > .clipped-container > .sheet > .table-row-cell .table-cell:selected {
-fx-background: -fx-selection-bar;
-fx-table-cell-border-color: derive(-fx-selection-bar, 20%);
}
这会将-fx-background
选定行中单元格中-fx-selection-bar
的-fx-table-cell-border-color
查找颜色设置为比它亮 20% 的颜色。
根据table-cell
这些通过定义其边框颜色
.table-cell {
-fx-padding: 0.166667em; /* 2px, plus border adds 1px */
-fx-background-color: null;
-fx-border-color: transparent -fx-table-cell-border-color transparent transparent;
-fx-cell-size: 2.0em; /* 24 */
-fx-text-fill: -fx-text-background-color;
}
因此,在选定行的单元格中,您会看到由 定义的右边框-fx-selection-bar
。
的默认设置-fx-selection-bar
位于样式表顶部附近:
/* A bright blue for highlighting/accenting objects. For example: selected
* text; selected items in menus, lists, trees, and tables; progress bars */
-fx-accent: #0096C9;
/* ... */
-fx-selection-bar: -fx-accent;
-fx-accent
因此,您可以通过重新定义表格视图来移除此边框:
.table-view {
-fx-accent: transparent ;
-fx-faint-focus-color: transparent;
-fx-focus-color: transparent;
}
推荐阅读
- python - 如何在熊猫数据框中选择地理区域内的对象
- python-3.x - 无法使用 pip 安装 speex
- angularjs - 从指令向父元素添加类
- azure-devops - 是否可以隐藏 Azure DevOps Wiki 中的页面?
- python - Python:Glob 只读取一个文件而不是两个
- multithreading - 为什么加入一个线程最终会调用多个线程?
- java - 是否可以将 ZipOutputStream 和 DigestOutputstream 结合起来?
- powershell - 使用 AAD 身份验证调用 Sqlcmd
- java - 字符串扫描仪
- java - 如果 auto-commit=false,Hikari DataSource 在 Spring Boot 中返回 null