changeset 6413:cbb89489baea

[TOYS] HelloFonts, correcting table cell handling to get rid of bogus error msg
author ddhill
date Wed, 05 Mar 2014 14:13:25 -0500
parents a080ea040a9c
children dc63b991dc39
files apps/toys/Hello/src/main/java/hello/HelloFonts.java
diffstat 1 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/apps/toys/Hello/src/main/java/hello/HelloFonts.java	Wed Mar 05 10:36:02 2014 -0800
+++ b/apps/toys/Hello/src/main/java/hello/HelloFonts.java	Wed Mar 05 14:13:25 2014 -0500
@@ -105,10 +105,14 @@
         column2.setCellFactory(param -> new TableCell<FontData, Font>() {
             @Override
             protected void updateItem(Font item, boolean empty) {
-//                        if (item == getItem()) return;
-                if (item == null) System.err.println("**********NULL why is it null");
-                setText(sampleText);
-                if (item != null) setFont(item);
+                super.updateItem(item, empty);
+
+                if (empty) {
+                    setText(null);
+                } else {
+                    setText(sampleText);
+                    setFont(item);
+                }
             }
         });
         table.setItems(FXCollections.observableList(data));
@@ -149,10 +153,14 @@
         column4.setCellFactory(param -> new TableCell<FontData, Font>() {
             @Override
             protected void updateItem(Font item, boolean empty) {
-//                        if (item == getItem()) return;
-                if (item == null) System.err.println("**********NULL why is it null");
-                setText(sampleText);
-                if (item != null) setFont(item);
+                super.updateItem(item, empty);
+
+                if (empty) {
+                    setText(null);
+                } else {
+                    setText(sampleText);
+                    setFont(item);
+                }
             }
         });