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

Compatibility issue: NullPointerException in TextField when bound bidirectional

    Details

      Description

      I get a NullPointerException, when I bindBidirectional a TextField to a StringProperty and start typing in the text field.

      java.lang.NullPointerException
      at com.sun.javafx.scene.control.behavior.TextInputControlBehavior.defaultKeyTyped(Unknown Source)
      at com.sun.javafx.scene.control.behavior.TextInputControlBehavior.callAction(Unknown Source)
      at com.sun.javafx.scene.control.behavior.BehaviorBase.callActionForEvent(Unknown Source)
      at com.sun.javafx.scene.control.behavior.TextInputControlBehavior.callActionForEvent(Unknown Source)
      at com.sun.javafx.scene.control.behavior.BehaviorBase$1.handle(Unknown Source)
      at com.sun.javafx.scene.control.behavior.BehaviorBase$1.handle(Unknown Source)
      at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
      at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
      at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
      at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
      at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
      at javafx.event.Event.fireEvent(Unknown Source)
      at javafx.scene.Scene$KeyHandler.process(Unknown Source)
      at javafx.scene.Scene$KeyHandler.access$2300(Unknown Source)
      at javafx.scene.Scene.impl_processKeyEvent(Unknown Source)
      at javafx.scene.Scene$ScenePeerListener.keyEvent(Unknown Source)
      at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleKeyEvent(Unknown Source)

      Workaround: If I initilialize the StringProperty with an empty String, it doesn't occur, but this is still a compatibility issue. It worked in 2.1.



      public class TestApp extends Application {
          public static void main(String[] args) {
              launch(args);
          }


          @Override
          public void start(Stage stage) throws Exception {

              TextField textField = new TextField();
              textField.textProperty().bindBidirectional(property);

              Scene scene = new Scene(textField);
              stage.setScene(scene);
              stage.show();
          }

          private StringProperty property = new SimpleStringProperty();
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                leifs Leif Samuelsson (Inactive)
                Reporter:
                cschudtjfx Christian Schudt (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: