diff --git a/modules/controls/src/main/java/javafx/scene/control/Cell.java b/modules/controls/src/main/java/javafx/scene/control/Cell.java --- a/modules/controls/src/main/java/javafx/scene/control/Cell.java +++ b/modules/controls/src/main/java/javafx/scene/control/Cell.java @@ -683,8 +683,13 @@ if (selected && isEmpty()) return; setSelected(selected); } - - + + // default implementation tests against equality + protected boolean isChanged(T oldValue, T newValue) { + return oldValue != null ? !oldValue.equals(newValue) : newValue != null; + } + + /*************************************************************************** * * * Stylesheet Handling * diff --git a/modules/controls/src/main/java/javafx/scene/control/ListCell.java b/modules/controls/src/main/java/javafx/scene/control/ListCell.java --- a/modules/controls/src/main/java/javafx/scene/control/ListCell.java +++ b/modules/controls/src/main/java/javafx/scene/control/ListCell.java @@ -461,7 +461,7 @@ // RT-35864 - if the index didn't change, then avoid calling updateItem // unless the item has changed. if (oldIndex == index) { - if (oldValue != null ? oldValue.equals(newValue) : newValue == null) { + if (!isChanged(oldValue, newValue)) { // RT-37054: we break out of the if/else code here and // proceed with the code following this, so that we may // still update references, listeners, etc as required. diff --git a/modules/controls/src/main/java/javafx/scene/control/TableCell.java b/modules/controls/src/main/java/javafx/scene/control/TableCell.java --- a/modules/controls/src/main/java/javafx/scene/control/TableCell.java +++ b/modules/controls/src/main/java/javafx/scene/control/TableCell.java @@ -647,7 +647,7 @@ // RT-35864 - if the index didn't change, then avoid calling updateItem // unless the item has changed. if (oldIndex == index) { - if (oldValue != null ? oldValue.equals(newValue) : newValue == null) { + if (!isChanged(oldValue, newValue)) { // RT-36670: we need to check the row item here to prevent // the issue where the cell value and index doesn't change, // but the backing row object does. diff --git a/modules/controls/src/main/java/javafx/scene/control/TableRow.java b/modules/controls/src/main/java/javafx/scene/control/TableRow.java --- a/modules/controls/src/main/java/javafx/scene/control/TableRow.java +++ b/modules/controls/src/main/java/javafx/scene/control/TableRow.java @@ -249,7 +249,7 @@ // RT-35864 - if the index didn't change, then avoid calling updateItem // unless the item has changed. if (oldIndex == newIndex) { - if (oldValue != null ? oldValue.equals(newValue) : newValue == null) { + if (!isChanged(oldValue, newValue)) { // RT-37054: we break out of the if/else code here and // proceed with the code following this, so that we may // still update references, listeners, etc as required. diff --git a/modules/controls/src/main/java/javafx/scene/control/TreeCell.java b/modules/controls/src/main/java/javafx/scene/control/TreeCell.java --- a/modules/controls/src/main/java/javafx/scene/control/TreeCell.java +++ b/modules/controls/src/main/java/javafx/scene/control/TreeCell.java @@ -505,7 +505,7 @@ // RT-35864 - if the index didn't change, then avoid calling updateItem // unless the item has changed. if (oldIndex == index) { - if (oldValue != null ? oldValue.equals(newValue) : newValue == null) { + if (!isChanged(oldValue, newValue)) { // RT-37054: we break out of the if/else code here and // proceed with the code following this, so that we may // still update references, listeners, etc as required. diff --git a/modules/controls/src/main/java/javafx/scene/control/TreeTableCell.java b/modules/controls/src/main/java/javafx/scene/control/TreeTableCell.java --- a/modules/controls/src/main/java/javafx/scene/control/TreeTableCell.java +++ b/modules/controls/src/main/java/javafx/scene/control/TreeTableCell.java @@ -638,7 +638,7 @@ // RT-35864 - if the index didn't change, then avoid calling updateItem // unless the item has changed. if (oldIndex == index) { - if (oldValue != null ? oldValue.equals(newValue) : newValue == null) { + if (!isChanged(oldValue, newValue)) { // RT-36670: we need to check the row item here to prevent // the issue where the cell value and index doesn't change, // but the backing row object does.