ListCellSkin: cleanup to not use (misbehaving) listeners ..

Jeanette Winzenburg fastegal at
Tue Jun 9 13:41:23 UTC 2020

After a couple of days spent to understand why/how ListCellSkin  
listening to the listView's fixedCellSize is misbehaving (there are  
multiple stumbling stones in its listener registration, details in the  
bug report - I'm  
about to remove that listener completely.

All it does is to copy the value of the listView's fixedCellSize to  
the skin, without any action triggered. Later on, that copied value is  
used in the computeXXHeight methods.

Code snippets:

     // fields
     private double fixedCellSize;
     private boolean fixedCellSizeEnabled;

     // listener:
     registerChangeListener(listView.fixedCellSizeProperty(), e -> {
         this.fixedCellSize = getSkinnable().getListView().getFixedCellSize();
         this.fixedCellSizeEnabled = fixedCellSize > 0;

     // usage
     protected double computePrefHeight(...) {
         if (fixedCellSizeEnabled) {
             return fixedCellSize;
         // do the per-row calc ...

Instead of keeping the fields in-sync with those of the listView, we  
could just query the current state:

     protected double computePrefHeight(...) {
         double fixedCellSize = getFixedCellSize();
         if (fixedCellSize > 0) {
             return fixedCellSize;
         // do the per-row calc ...

     double getFixedCellSize() {
         ListView<?> listView = getSkinnable().getListView();
         return listView != null ? listView.getFixedCellSize() :  

Doing so would by-pass the pitfalls of corrently re-wiring the  
listener to the path property (it's added complexity without benefit).  
Plus cleanup unneeded aliasing (which I think is a code smell anyway)

Opinions, please

-- Jeanette

More information about the openjfx-dev mailing list