Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8151524

XXCellSkin: throws NPE on instantiation

XMLWordPrintable

      XX for List/Tree/TreeTableRow

      Happens if the cell is not yet attached to a List/Tree/TableView (there might be others, didn't really dig), see failing tests below. In real-world scenarios, this might happen if custom skins are set in a cellFactory.

      incorrect assumption ;-) The part in square brackets happens a couple of lines later ...
      [
      The technical reason is that skin registeres a changeListener to a property of the containing view, that is something like

      registerChangeListener(cell.getXXView().getSomeProperty(), ....)

      Technical solution is to move the binding into the listener to the cell.XXView property
      ]

      Constructor is directly accessing the indirect property:

      for list/tree

      this.fixedCellSize = control.getTreeView().getFixedCellSize();

      for treeTableRow, it's buried a bit deeper ... getVisibleColumns assumes that the cell is attached to a containing view

      Failing tests:

          /**
           * Test about treeTableRowSkin: registers
           * a listener on the treeTableView treeColumn in constructor
           * - throws if not yet bound to a treeTable
           */
          @Test
          public void testTreeTableRowSkinInit() {
              TreeTableRow row = new TreeTableRow();
              row.setSkin(new TreeTableRowSkin(row));
          }
          
          @Test
          public void testListCellSkinInit() {
              ListCell cell = new ListCell();
              cell.setSkin(new ListCellSkin(cell));
          }
          
          @Test
          public void testTreeCellSkin() {
              TreeCell cell = new TreeCell();
              cell.setSkin(new TreeCellSkin(cell));
          }


            jgiles Jonathan Giles
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: