StringBinding and null

Michael Heinrichs michael.heinrichs at
Wed Jan 20 07:21:25 UTC 2016

Hi Scott,

if I remember correctly, the behavior you observe and would like to change is actually not defined in StringBinding, but in the  method asString(). You can fix it by defining your own StringBinding. It is a one-liner, guess you are way better off doing it yourself than waiting for such a change to make it into the official release. ;)


> On 19 Jan 2016, at 17:09, Scott Palmer <swpalmer at> wrote:
> So I just discovered that:
> ObjectProperty<String> objectPropertyString = new
> SimpleObjectProperty<>(null);
> StringBinding stringBinding = objectPropertyString.asString();
> stringBinding.get() == null --> FALSE
> stringBinding.get().equals("null") --> TRUE
> I care because this fails to do what I want:
> Button okayButton;
> ComboBox<String> combo;
> //...
> BooleanBinding dontHaveValue =
> Bindings.isEmpty(combo.valueProperty().asString());
> okayButton.disableProperty().bind(dontHaveValue);
> The behaviour is understandable and obviously too late to change even if we
> wanted to (which we probably don't).  But I wonder if StringBinding can be
> tweaked so you can enable the pass through of null if you choose to?
> If others agree I will open an issue.
> Scott

More information about the openjfx-dev mailing list