JavaFX 9/10不再可能覆盖TableView.resizeColumnToFitContent [英] JavaFX 9/10 no longer possible to override TableView.resizeColumnToFitContent

查看:74
本文介绍了JavaFX 9/10不再可能覆盖TableView.resizeColumnToFitContent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaFX 8中,可以覆盖TableView.resizeColumnToFitContent函数.这对于我们的目的至关重要,因为它使我们能够改进列标题的布局方式,而不是默认实现,以及在较大表中默认值遭受某些影响的情况下调整性能.

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.

如何增强布局行为的一个示例是在嵌套列标题的上下文中.默认情况下,叶列标题的prefWidth根据该列中数据行的最大宽度或叶列标题文本的宽度(以较大者为准)进行设置.但是,如果该叶标题具有一些带有较宽标题文本的父列标题,则它们将被剪切并显示省略号.这对我们来说不是理想的,因此我们已更改resizeColumnToFitContent,因此叶列标题的prefWidth也考虑了其父列标题的prefWidth.

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.

从Java 9及以下版本开始,resizeColumnToFitContent函数已移至静态位置,从而删除了自定义此行为的功能:

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

大约一周前,我写信给负责此更改的作者乔纳森·吉尔斯(Jonathan Giles),但我想他是一个忙碌的人,这已经成为我们和我们计划将产品迁移到Java 10的一个棘手问题.我还要看看社区是否知道我该如何解决.到目前为止,唯一的选择似乎是某种蛮力的方法概述,但是也许有更好的方法?

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?

推荐答案

如果要覆盖此方法,为什么不像TableSkinUtils中那样实现自己的resizeColumnToFitContent?

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

这篇关于JavaFX 9/10不再可能覆盖TableView.resizeColumnToFitContent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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