http://stackoverflow.com/questions/12324464/how-to-javafx-hide-background-header-of-a-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

2 Answers

The solution is very simple; after the tableview renders, we can get the table header and make invisible, therefor the table header doesn't have to re-layout when the table view layout changes. To catch table rendering is done, we can use width property change, and hide the table header

Here is the code:

tableView.widthProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
// Get the table header
Pane header = (Pane)tableView.lookup("TableHeaderRow");
if(header!=null && header.isVisible()) {
header.setMaxHeight(0);
header.setMinHeight(0);
header.setPrefHeight(0);
header.setVisible(false);
header.setManaged(false);
}
}
});

**********************************************

Apply a custom stylesheet to the table:

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

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; }

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;.

   
Thanks jewelsea, but this will keep an empty space instead of the column header, and I want to remove it. –  Anas Aswad Sep 11 '12 at 11:08
   
Added a -fx-padding setting to the suggested css so that the invible column header does not take up any space on the screen (as recommended by an anonymous stackoverflow user). –  jewelsea Jun 5 at 21:53

how to javafx hide background header of a tableview?的更多相关文章

  1. javafx将数据库内容输出到tableview表格

    一 .创建Fxml文件,用Javafx Scene Builder 编辑页面,创建tableview(表格)和tablecolum(表格中的列),并为其设置fxid: 二.生成fxml文件的控制类: ...

  2. javafx基于使用fxml布局的tableview数据绑定用法

    来个简单明了的 fxml的tableview数据绑定和java代码方式的数据绑定很像,不同的在于要有一到映射 首先看个目录 1.界面文件Sample.fxml <?xml version=&qu ...

  3. iOS UITableView ExpandableHeader(可形变的Header)

    最常见的header就是在tableView下拉时header里的图片会放大的那种, 最近研究了一下,自己实现了这种header. 1.设置TableView的contentInset(为header ...

  4. JavaScript资源大全中文版(Awesome最新版)

    Awesome系列的JavaScript资源整理.awesome-javascript是sorrycc发起维护的 JS 资源列表,内容包括:包管理器.加载器.测试框架.运行器.QA.MVC框架和库.模 ...

  5. python解析git log后生成页面显示git更新日志信息

    使用git log可以查到git上项目的更新日志. 如下两个git项目,我想把git的日志信息解析成一个便于在浏览器上查看的页面. https://github.com/gityf/lua https ...

  6. 知问前端——Ajax提交表单

    本文,运用两大表单插件,完成数据表新增的工作. 一.创建数据库 创建一个数据库,名称为:zhiwen,表——user表,字段依次为:id.name.pass.email.sex.birthday.da ...

  7. wesome-android

    awesome-android Introduction android libs from github System requirements Android Notice If the lib ...

  8. Github上有趣的资料 | JS

    留着,以后用得着,原文地址:http://www.jianshu.com/p/7c9aa9508641 collection AlloyImage 基于HTML5的专业级图像处理开源引擎.An ima ...

  9. UITableView的创建及其一些常用方法

    UITableView,它的数据源继承于UITableViewDataSource,它的委托UITableViewDelegate. 一.UITableView的创建 1.代码方式: UITableV ...

随机推荐

  1. 浅析Java web程序之客户端和服务器端交互原理(转)

    转载自http://www.cnblogs.com/lys_013/archive/2012/05/05/2484561.html 1. 协议 a. TCP/IP整体构架概述 TCP/IP协议并不完全 ...

  2. JavaScript关闭窗口的方法

    当你创建了一个新窗口时,将open()方法的返回值分配给一个变量非常重要.比如,下面的语句就是创建一个新窗口,然后立即关闭它: win = window.open("http://www.d ...

  3. Machine Learning for hackers读书笔记(一)使用R语言

    #使用数据:UFO数据 #读入数据,该文件以制表符分隔,因此使用read.delim,参数sep设置分隔符为\t #所有的read函数都把string读成factor类型,这个类型用于表示分类变量,因 ...

  4. 51nod1364 最大字典序排列

    不断的在cur的后面找最大的符合条件的数扔到cur的前面. 用线段树维护操作就可以了. #include<cstdio> #include<cstring> #include& ...

  5. BZOJ 1617 渡河问题

    普及组dp. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm ...

  6. 移动金融APP分析

    最近研究了移动互联网金融APP的情况,分享给大家. 这是官方关于互联网金融的范围,包括支付.借贷.众筹.基金.保险和信托. 典型的APP 绑卡的流程普遍采用的四要素鉴权:姓名,身份证,卡号以及银行预留 ...

  7. *ecshop 模板中foreach用法详解

    1.foreach分以下几个参数 from, item, name, iteration, index 2.使用foreach循环      如果php要传递一个数组(如:$array)给ecshop ...

  8. (六)6.9 Neurons Networks softmax regression

    SoftMax回归模型,是logistic回归在多分类问题的推广,即现在logistic回归数据中的标签y不止有0-1两个值,而是可以取k个值,softmax回归对诸如MNIST手写识别库等分类很有用 ...

  9. 【英语】Bingo口语笔记(43) - u长短音

  10. 【英语】Bingo口语笔记(52) - sleep系列