On Wed, 23 Mar 2022 08:17:38 GMT, Marius Hanl <mh...@openjdk.org> wrote:

>> This fix respects a row factory, if present.
>> It will put the cell that is used to measure the column width as child below 
>> the row.
>> In that way the row's style will be used.
>
> modules/javafx.controls/src/main/java/javafx/scene/control/skin/TableColumnHeader.java
>  line 653:
> 
>> 651:         tableSkin.getChildren().add(tableRow);
>> 652:         tableRow.applyCss();
>> 653:         ((SkinBase<?>) tableRow.getSkin()).getChildren().add(cell);
> 
> I don't think this is a safe cast. Instead, you probably should do an 
> `instanceof SkinBase` check before

You're right. A tablerow may have been created that returns a custom skin which 
is not necessarily derived from SkinBase. 
However, since we do not have a getChildren() method in such a custom skin we 
will be unable to proceed. We could now abandon altogether (another return) but 
that mean that resizeColumnToFitContent no longer works at all in the presence 
of custom rows. So I think the best solution in that case would be to ignore 
the rowFactory and use a default `new TableRow<>` again to preserve at least 
the old behaviour in such cases.
I'll try and improve the patch.

-------------

PR: https://git.openjdk.java.net/jfx/pull/757

Reply via email to