如何javafx隐藏tableview的背景标题? [英] how to javafx hide background header of a tableview?

查看:884
本文介绍了如何javafx隐藏tableview的背景标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发自动完整文本,其中显示了tableview弹出窗口中的建议下拉列表,我遇到了如何在javafx 2.1中隐藏tableview的整个标题列的问题

I'm trying to develop auto complete text, which shows a dropdown of suggestions in tableview popup, and I'm having an issue of how can I hide the whole header-column of tableview in javafx 2.1

推荐答案

将自定义样式表应用于表格:

Apply a custom stylesheet to the table:

table.getStylesheets().addAll(getClass().getResource("hidden-tableview-headers.css").toExternalForm());

文件 hidden-tableview-headers.css 与加载css资源的类放在同一位置,并包含以下行:

Where the file hidden-tableview-headers.css is placed in the same location as the class loading the css resource and contains the line:

.column-header-background { visibility: hidden; -fx-padding: -1em; }

visibility:hidden 属性告诉JavaFX不绘制节点,但仍留有标题所在的空间。由于标题是1行文本高度高,您可以通过设置 -fx-padding:-1em; 来判断不可见标题不占用任何空格。

The visibility: hidden attribute tells JavaFX not to draw the node, but still leave space where the heading was. As the header is 1 row of text height high, you can tell the invisible header not to take up any space by setting -fx-padding: -1em;.

这篇关于如何javafx隐藏tableview的背景标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆