java - JavaFX TextArea. The application crashes when using appendText too quick. Any suggestion? -


i updating string content of javafx.scene.control.textarea different thread, adding sentence @ time.

this listener method append textarea (named display):

public void onstatus(status status) {         if(userfilters.statusmatches(status)){              display.appendtext("@"                  + status.getuser().getscreenname() + "\n"                  + status.gettext() + "\n-------------\n");         } } 

if rate of posting not excessively quick, works.

otherwise, if incoming messages many (e.g. public posts taken social network), application 'graphical update' crash after few of them.

the exceptions not refers elements of code have written. not know how catch them , stop application in sort of clean way.

(by way, not trying append null element.)

these exceptions:

exception in thread "javafx application thread" java.lang.nullpointerexception @ com.sun.javafx.text.prismtextlayout.getruns(prismtextlayout.java:236) @ javafx.scene.text.text.getruns(text.java:317) @ javafx.scene.text.text.updatepgtext(text.java:1465) @ javafx.scene.text.text.impl_updatepeer(text.java:1500) @ javafx.scene.node.impl_syncpeer(node.java:503) @ javafx.scene.scene$scenepulselistener.synchronizescenenodes(scene.java:2290) @ javafx.scene.scene$scenepulselistener.pulse(scene.java:2419) @ com.sun.javafx.tk.toolkit.lambda$runpulse$30(toolkit.java:314) @ com.sun.javafx.tk.toolkit$$lambda$122/1010826311.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ com.sun.javafx.tk.toolkit.runpulse(toolkit.java:313) @ com.sun.javafx.tk.toolkit.firepulse(toolkit.java:340) @ com.sun.javafx.tk.quantum.quantumtoolkit.pulse(quantumtoolkit.java:525) @ com.sun.javafx.tk.quantum.quantumtoolkit.pulse(quantumtoolkit.java:505) @ com.sun.javafx.tk.quantum.quantumtoolkit.lambda$runtoolkit$400(quantumtoolkit.java:334) @ com.sun.javafx.tk.quantum.quantumtoolkit$$lambda$41/1654631781.run(unknown source) @ com.sun.glass.ui.invokelaterdispatcher$future.run(invokelaterdispatcher.java:95)  exception in thread "javafx application thread" java.lang.nullpointerexception @ com.sun.javafx.text.prismtextlayout.addtextrun(prismtextlayout.java:755) @ com.sun.javafx.text.glyphlayout.addtextrun(glyphlayout.java:121) @ com.sun.javafx.text.glyphlayout.breakruns(glyphlayout.java:191) @ com.sun.javafx.text.prismtextlayout.buildruns(prismtextlayout.java:770) @ com.sun.javafx.text.prismtextlayout.layout(prismtextlayout.java:1021) @ com.sun.javafx.text.prismtextlayout.ensurelayout(prismtextlayout.java:223) @ com.sun.javafx.text.prismtextlayout.getbounds(prismtextlayout.java:246) @ javafx.scene.text.text.getlogicalbounds(text.java:358) @ javafx.scene.text.text.impl_computegeombounds(text.java:1168) @ javafx.scene.node.updategeombounds(node.java:3556) @ javafx.scene.node.getgeombounds(node.java:3509) @ javafx.scene.node.getlocalbounds(node.java:3457) @ javafx.scene.node$miscproperties$2.computebounds(node.java:6451) @ javafx.scene.node$lazyboundsproperty.get(node.java:9285) @ javafx.scene.node$lazyboundsproperty.get(node.java:9255) @ javafx.scene.node.getboundsinlocal(node.java:3135) @ com.sun.javafx.scene.control.skin.textareaskin$contentview.layoutchildren(textareaskin.java:207) @ javafx.scene.parent.layout(parent.java:1076) @ javafx.scene.parent.layout(parent.java:1082) @ javafx.scene.parent.layout(parent.java:1082) @ javafx.scene.parent.layout(parent.java:1082) @ javafx.scene.parent.layout(parent.java:1082) @ javafx.scene.parent.layout(parent.java:1082) @ javafx.scene.parent.layout(parent.java:1082) @ javafx.scene.scene.dolayoutpass(scene.java:552) @ javafx.scene.scene$scenepulselistener.pulse(scene.java:2397) @ com.sun.javafx.tk.toolkit.lambda$runpulse$30(toolkit.java:314) @ com.sun.javafx.tk.toolkit$$lambda$122/1010826311.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ com.sun.javafx.tk.toolkit.runpulse(toolkit.java:313) @ com.sun.javafx.tk.toolkit.firepulse(toolkit.java:340) @ com.sun.javafx.tk.quantum.quantumtoolkit.pulse(quantumtoolkit.java:525) @ com.sun.javafx.tk.quantum.quantumtoolkit.pulse(quantumtoolkit.java:505) @ com.sun.javafx.tk.quantum.quantumtoolkit.lambda$runtoolkit$400(quantumtoolkit.java:334) @ com.sun.javafx.tk.quantum.quantumtoolkit$$lambda$41/1654631781.run(unknown source) @ com.sun.glass.ui.invokelaterdispatcher$future.run(invokelaterdispatcher.java:95) @ com.sun.javafx.text.prismtextlayout.layout(prismtextlayout.java:1063) @ com.sun.javafx.text.prismtextlayout.ensurelayout(prismtextlayout.java:223) @ com.sun.javafx.text.prismtextlayout.getbounds(prismtextlayout.java:246) @ javafx.scene.text.text.getlogicalbounds(text.java:358) @ javafx.scene.text.text.impl_computegeombounds(text.java:1168) @ javafx.scene.node.updategeombounds(node.java:3556) @ javafx.scene.node.getgeombounds(node.java:3509) @ javafx.scene.node.getlocalbounds(node.java:3457) @ javafx.scene.node.updatetxbounds(node.java:3620) @ javafx.scene.node.gettransformedbounds(node.java:3403) @ javafx.scene.node.updatebounds(node.java:538) @ javafx.scene.parent.updatebounds(parent.java:1706) @ javafx.scene.parent.updatebounds(parent.java:1706) @ javafx.scene.parent.updatebounds(parent.java:1706) @ javafx.scene.parent.updatebounds(parent.java:1706) @ javafx.scene.parent.updatebounds(parent.java:1706) @ javafx.scene.parent.updatebounds(parent.java:1706) @ javafx.scene.parent.updatebounds(parent.java:1706) @ javafx.scene.parent.updatebounds(parent.java:1706) @ javafx.scene.scene$scenepulselistener.pulse(scene.java:2404) @ com.sun.javafx.tk.toolkit.lambda$runpulse$30(toolkit.java:314) @ com.sun.javafx.tk.toolkit$$lambda$122/1010826311.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ com.sun.javafx.tk.toolkit.runpulse(toolkit.java:313) @ com.sun.javafx.tk.toolkit.firepulse(toolkit.java:340) @ com.sun.javafx.tk.quantum.quantumtoolkit.pulse(quantumtoolkit.java:525) @ com.sun.javafx.tk.quantum.quantumtoolkit.pulse(quantumtoolkit.java:505) @ com.sun.javafx.tk.quantum.quantumtoolkit.lambda$runtoolkit$400(quantumtoolkit.java:334) @ com.sun.javafx.tk.quantum.quantumtoolkit$$lambda$41/1654631781.run(unknown source) @ com.sun.glass.ui.invokelaterdispatcher$future.run(invokelaterdispatcher.java:95)  exception in thread "javafx application thread" java.lang.arrayindexoutofboundsexception exception in thread "javafx application thread" java.lang.arrayindexoutofboundsexception exception in thread "javafx application thread" java.lang.arrayindexoutofboundsexception exception in thread "javafx application thread" java.lang.arrayindexoutofboundsexception exception in thread "javafx application thread" java.lang.arrayindexoutofboundsexception 

(...and forth...)

both exceptions thrown because variable lines null inside prismtextlayout. why null? set null every time append text text area in method (this called append):

com.sun.javafx.text.prismtextlayout.reset(prismtextlayout.java:92) 

the lines var isn't null because every time scene rendered reset. getting npe because calling between lines being set null , being reset normal value.

the solution call append javafx app thread (i.e. use runlater(() -> ...) appending ta).


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -