changeset 1404:c74fc98bb9d4

RT-23008: TextFieldListCell throws NPE on Enter
author jgiles
date Tue, 03 Jul 2012 12:12:30 +1200
parents dffc6988a9ab
children 587765f2009d
files javafx-ui-controls/src/javafx/scene/control/cell/CellUtils.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/javafx/scene/control/cell/CellUtils.java	Mon Jul 02 13:05:18 2012 -0700
+++ b/javafx-ui-controls/src/javafx/scene/control/cell/CellUtils.java	Tue Jul 03 12:12:30 2012 +1200
@@ -96,7 +96,7 @@
             converter.toString(cell.getItem());
     }
     
-    
+
     
     /***************************************************************************
      *                                                                         *
@@ -191,6 +191,12 @@
         textField.setOnKeyReleased(new EventHandler<KeyEvent>() {
             @Override public void handle(KeyEvent t) {
                 if (t.getCode() == KeyCode.ENTER) {
+                    if (converter == null) {
+                        throw new IllegalStateException(
+                            "Attempting to convert text input into Object, but provided "
+                                + "StringConverter is null. Be sure to set a StringConverter "
+                                + "in your cell factory.");
+                    }
                     cell.commitEdit(converter.fromString(textField.getText()));
                 } else if (t.getCode() == KeyCode.ESCAPE) {
                     cell.cancelEdit();