JavaFX 9/10 no longer possible to override TableView.resizeColumnToFitContent

自闭症网瘾萝莉.ら 提交于 2019-12-08 05:22:26

问题


In JavaFX 8 it was possible to override the TableView.resizeColumnToFitContent function. This is vital for our purposes since it allows us to enhance the way column headers are laid out beyond the default implementation, as well as to tune the performance where the default suffers somewhat in larger tables.

One example of how the layout behaviour has been enhanced is in the context of nested column headers. By default a leaf column header's prefWidth is set according to either the max width of the rows of data in that column, or to the width of the leaf column's title text, whichever is greater. But if that leaf header has some parent column headers with wider title text, they'll be clipped and an ellipsis displayed. This is not desirable for us, so we've changed resizeColumnToFitContent so the prefWidth of a leaf column header also takes into account the prefWidth of its parent column headers.

As of Java 9 and the below commit, the resizeColumnToFitContent function has been moved to a static location, removing the ability to customise this behaviour:

http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/53bfdfed5bbf

About a week ago I wrote to the author responsible for this change, Jonathan Giles, but I guess he's a busy guy and this is becoming a blocking issue for us and our plans to migrate our product to Java 10, so I thought I'd also see if the community knows how I might solve this. So far, the only option seems to be the somewhat brute force approach outlined here, but maybe there's a better way?


回答1:


If you want to override this method, why you just don't implement your own resizeColumnToFitContent like is was in TableSkinUtils ?



来源:https://stackoverflow.com/questions/50583912/javafx-9-10-no-longer-possible-to-override-tableview-resizecolumntofitcontent

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