1

I have a JavaFX Text whose textProperty is bound to a String in a separate thread that represents a time for a countdown timer that is throwing an error. It never throws this error when the textProperty is only changed once per second but when it starts updating every 1/100 second it will work for a few seconds and then I get this error:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at javafx.scene.Scene$ScenePulseListener.synchronizeSceneNodes(Unknown Source)
at javafx.scene.Scene$ScenePulseListener.pulse(Unknown Source)
at com.sun.javafx.tk.Toolkit.lambda$runPulse$30(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.Toolkit.runPulse(Unknown Source)
at com.sun.javafx.tk.Toolkit.firePulse(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$404(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I came across this topic, JavaFX append text to TextArea throws Exception, which seems to have a similar problem. Is it because I am updating the Text too often and if so is there a better way do this? Thanks

Community
  • 1
  • 1
Trevor M
  • 191
  • 1
  • 6
  • 3
    As the rendering of a JavaFX application it tiggered by pulses and there are at max 60 pulses per second, you are overwelming the application thead, the calls get postponed and this may lead to this behavior. Try to reduce the number of updates. See the [Oracle documentation](https://docs.oracle.com/javafx/2/architecture/jfxpub-architecture.htm). – hotzst May 06 '16 at 10:03

0 Answers0