Bug: Not on FX application thread exception is inconsistent
Tom Schindl
tom.schindl at bestsolution.at
Mon Nov 12 23:39:45 UTC 2018
Hi,
You are supposed to interact with Nodes who are currently shown in the
SG only only the JavaFX Application Thread.
JavaFX although is not checking each and every property (change) as this
would be too resource intensive but at sensitive cases (eg when
interacting with Glass) it does check that you run on the correct thread.
Even though your TableView, ... updates seem to work you can run into
disasterous states - see eg https://bugs.openjdk.java.net/browse/JDK-8198577
Tom
On 10.11.18 06:58, Ty Young wrote:
> Hi,
>
>
> My JavaFX program updates API objects in the background via a non FX
> thread that, when changed by another program, are reflected in my JavaFX
> GUI's controls by property binding, specifically TableView, Slider,
> TextField, and ComboBox. Problem is, while JavaFX is OK with this for
> TableView, Slider, and TextField, it throws a Not on FX application
> thread exception *only* for the ComboBox.
>
>
> The code for the slider looks like this:
>
> private class ValueListener implements ChangeListener<Integer>
> {
> @Override
> public void changed(ObservableValue<? extends Integer>
> observable, Integer oldValue, Integer newValue)
> {
> slider.getSlider().setValue(newValue);
> slider.getTextBox().setText(newValue.toString());
> }
> }
>
>
> (the slider variable is misleading, it's actually a VBox that contains a
> Slider and a TextField. Need to change it but I digress.)
>
>
> which works fine. However this:
>
>
> private class ValueListener implements ChangeListener<E>
> {
> @Override
> public void changed(ObservableValue<? extends E> observable, E
> oldValue, E newValue)
> {
> combo.setValue(newValue);
> }
> }
>
>
> doesn't for the ComboBox.
>
>
> Is this a bug or is there some legitimate invisible reason as to why the
> slider/textfield isn't throwing an error but the combobox one is?
>
>
>
--
Tom Schindl, CTO
BestSolution.at EDV Systemhaus GmbH
Eduard-Bodem-Gasse 5-7. A-6020 Innsbruck
Reg. Nr. FN 222302s am Firmenbuchgericht Innsbruck
More information about the openjfx-dev
mailing list