How to disable the reordering of table columns in tableView?

流过昼夜 提交于 2019-12-23 10:55:06

问题


Trying to figure out on how can i disable the reordering of table columns in javafx 2?


回答1:


Here's the solution:

tblView.getColumns().addListener(new ListChangeListener() {
        @Override
        public void onChanged(Change change) {
          change.next();
          if(change.wasReplaced()) {
              tblView.getColumns().clear();
              tblView.getColumns().addAll(column1,column2...);
          }
        }
    });



回答2:


After much waste of time, I've found the following, very simple, solution:

TableHeaderRow header = (TableHeaderRow) myTableView.lookup("TableHeaderRow");
header.setMouseTransparent(true);


来源:https://stackoverflow.com/questions/14116792/how-to-disable-the-reordering-of-table-columns-in-tableview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!