B4J Question [SOLVED] Java FX error on Release

Peter Lewis

Well-Known Member
Licensed User
Longtime User
Hi
I am getting this error only on release. So I did try adding this line and got the same error. Any ideas ? Thank you

#PackagerProperty: IncludedModules = javafx.web

Error only in Release

clsday._initialize (java line: 260)
java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-6
at javafx.graphics/com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:291)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:424)
at javafx.graphics/javafx.scene.Parent$3.onProposedChange(Parent.java:471)
at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:113)
at javafx.base/com.sun.javafx.collections.VetoableListDecorator.setAll(VetoableListDecorator.java:108)
at javafx.controls/javafx.scene.control.skin.LabeledSkinBase.updateChildren(LabeledSkinBase.java:272)
at javafx.controls/javafx.scene.control.skin.LabeledSkinBase.lambda$new$11(LabeledSkinBase.java:220)
at javafx.controls/com.sun.javafx.scene.control.LambdaMultiplePropertyChangeListenerHandler.lambda$new$1(LambdaMultiplePropertyChangeListenerHandler.java:49)
at javafx.base/javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:86)
at javafx.base/com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(ExpressionHelper.java:181)
at javafx.base/com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
at javafx.base/javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:104)
at javafx.base/javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:111)
at javafx.base/javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:145)
at javafx.base/javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:50)
at javafx.base/javafx.beans.property.StringProperty.setValue(StringProperty.java:65)
at javafx.controls/javafx.scene.control.Labeled.setText(Labeled.java:147)
at anywheresoftware.b4j.objects.LabeledWrapper.setText(LabeledWrapper.java:43)
at b4j.example.clsday._initialize(clsday.java:260)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at loseit.bytes507.BackWorker.createInstance(BackWorker.java:46)
at loseit.bytes507.BackWorker.access$100(BackWorker.java:16)
at loseit.bytes507.BackWorker$1.run(BackWorker.java:85)
at java.base/java.lang.Thread.run(Thread.java:834)
 

Daestrum

Expert
Licensed User
Longtime User
Hard to tell what is causing it in clsday without seeing any code.
Basically the error is you are updating the UI from a different thread - not allowed.

I believe (I may be wrong) that in debug the app runs single threaded so will always be on the fx thread, in release it can run on multiple threads.
 
Upvote 0

Peter Lewis

Well-Known Member
Licensed User
Longtime User
From the error it looks like you are trying to update the text of a control from a BackGround Worker which will be running on a non-UI thread.
Thank you, there was one field that I was updating in the Background worker , Which all I had to do was to give it a Value from the main thread. That seems to have solved it. Thank you
 
Upvote 0

Peter Lewis

Well-Known Member
Licensed User
Longtime User
Hard to tell what is causing it in clsday without seeing any code.
Basically the error is you are updating the UI from a different thread - not allowed.

I believe (I may be wrong) that in debug the app runs single threaded so will always be on the fx thread, in release it can run on multiple threads.
I did find one Label that I put in a Default value that worked. Thank you
 
Upvote 0
Top