TextField#setText(null)?

Tom Schindl tom.schindl at bestsolution.at
Mon Jul 16 14:05:52 PDT 2012


Hi,

Is it a problem in the JavaDoc but calling TextField#setText(null)
results not directly in an error but an NPE once you try to type
something into the control:

-----------8<-----------
TextField f = new TextField();
f.setText(null);
primaryStage.setScene(new Scene(b));
primaryStage.setWidth(200);
primaryStage.setHeight(200);
primaryStage.show();
-----------8<-----------

The line with the NPE is in TextInputControlBehavior.defaultKeyTyped
line 219

> undoManager.addChange(start, textInput.getText().substring(start, end), character, true);

textInput.getText() is null, the problem is when binding e.g. a bean
where the value is NULL initially one gets NPEs so this is a major bug.
If NULL is not allowed for f.setText() it should throw an
IllegalArgumentException immediately I think, not?

Tom

-- 
B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl                 geschäftsführer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5-7/1   A-6020 innsbruck     fax      ++43 512 935833
http://www.BestSolution.at                      phone    ++43 512 935834



More information about the openjfx-dev mailing list