JavaFx - 无尽的线程异常"JavaFX Application Thread" java.lang.NullPointerException

3
我遇到了以下异常,甚至不知道它出现在哪个位置。这是什么意思呢?
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
    at com.sun.javafx.text.PrismTextLayout.addTextRun(PrismTextLayout.java:755)
    at com.sun.javafx.text.GlyphLayout.addTextRun(GlyphLayout.java:140)
    at com.sun.javafx.text.GlyphLayout.breakRuns(GlyphLayout.java:210)
    at com.sun.javafx.text.PrismTextLayout.buildRuns(PrismTextLayout.java:770)
    at com.sun.javafx.text.PrismTextLayout.layout(PrismTextLayout.java:1021)
    at com.sun.javafx.text.PrismTextLayout.ensureLayout(PrismTextLayout.java:223)
    at com.sun.javafx.text.PrismTextLayout.getBounds(PrismTextLayout.java:246)
    at javafx.scene.text.Text.getLogicalBounds(Text.java:358)
    at javafx.scene.text.Text.impl_computeGeomBounds(Text.java:1168)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1724)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1516)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1724)
    at javafx.scene.Parent.updateCachedBounds(Parent.java:1588)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1527)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1724)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1516)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1724)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1516)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.computeLocalBounds(Node.java:3572)
    at javafx.scene.Node.updateLocalBounds(Node.java:3602)
    at javafx.scene.Node.getLocalBounds(Node.java:3463)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1724)
    at javafx.scene.Parent.updateCachedBounds(Parent.java:1588)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1527)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1724)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1516)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Parent.getChildTransformedBounds(Parent.java:1724)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1516)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.impl_intersectsBounds(Node.java:4992)
    at javafx.scene.layout.Region.impl_pickNodeLocal(Region.java:2931)
    at javafx.scene.Node.impl_pickNode(Node.java:4891)
    at javafx.scene.Scene$MouseHandler.pickNode(Scene.java:3899)
    at javafx.scene.Scene$MouseHandler.access$1600(Scene.java:3485)
    at javafx.scene.Scene.pick(Scene.java:1942)
    at javafx.scene.Scene.access$6700(Scene.java:159)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3711)
    at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
    at javafx.scene.Scene$MouseHandler$1.run(Scene.java:3521)
    at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
    at com.sun.javafx.application.PlatformImpl$$Lambda$59/1182424050.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
    at com.sun.javafx.application.PlatformImpl$$Lambda$58/1283229537.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$50(GtkApplication.java:139)
    at com.sun.glass.ui.gtk.GtkApplication$$Lambda$47/1609034571.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:418)
    at java.util.ArrayList.get(ArrayList.java:431)
    at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
    at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
    at javafx.scene.Parent.updateCachedBounds(Parent.java:1583)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1527)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Node.updateBounds(Node.java:538)
    at javafx.scene.Parent.updateBounds(Parent.java:1711)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2404)
    at com.sun.javafx.tk.Toolkit.lambda$runPulse$31(Toolkit.java:348)
    at com.sun.javafx.tk.Toolkit$$Lambda$167/1784277725.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:347)
    at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:374)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$405(QuantumToolkit.java:319)
    at com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$51/396808120.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$50(GtkApplication.java:139)
    at com.sun.glass.ui.gtk.GtkApplication$$Lambda$47/1609034571.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:418)
    at java.util.ArrayList.get(ArrayList.java:431)
    at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
    at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
    at javafx.scene.Parent.updateCachedBounds(Parent.java:1583)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1527)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Node.updateBounds(Node.java:538)
    at javafx.scene.Parent.updateBounds(Parent.java:1711)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2404)
    at com.sun.javafx.tk.Toolkit.lambda$runPulse$31(Toolkit.java:348)
    at com.sun.javafx.tk.Toolkit$$Lambda$167/1784277725.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:347)
    at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:374)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$405(QuantumToolkit.java:319)
    at com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$51/396808120.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$50(GtkApplication.java:139)
    at com.sun.glass.ui.gtk.GtkApplication$$Lambda$47/1609034571.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:418)
    at java.util.ArrayList.get(ArrayList.java:431)
    at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
    at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
    at javafx.scene.Parent.updateCachedBounds(Parent.java:1583)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1527)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Node.updateBounds(Node.java:538)
    at javafx.scene.Parent.updateBounds(Parent.java:1711)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2404)
    at com.sun.javafx.tk.Toolkit.lambda$runPulse$31(Toolkit.java:348)
    at com.sun.javafx.tk.Toolkit$$Lambda$167/1784277725.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:347)
    at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:374)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$405(QuantumToolkit.java:319)
    at com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$51/396808120.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$50(GtkApplication.java:139)
    at com.sun.glass.ui.gtk.GtkApplication$$Lambda$47/1609034571.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException: -1
    at java.util.ArrayList.elementData(ArrayList.java:418)
    at java.util.ArrayList.get(ArrayList.java:431)
    at com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
    at com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
    at javafx.scene.Parent.updateCachedBounds(Parent.java:1583)
    at javafx.scene.Parent.recomputeBounds(Parent.java:1527)
    at javafx.scene.Parent.impl_computeGeomBounds(Parent.java:1380)
    at javafx.scene.layout.Region.impl_computeGeomBounds(Region.java:3078)
    at javafx.scene.Node.updateGeomBounds(Node.java:3556)
    at javafx.scene.Node.getGeomBounds(Node.java:3509)
    at javafx.scene.Node.getLocalBounds(Node.java:3457)
    at javafx.scene.Node.updateTxBounds(Node.java:3620)
    at javafx.scene.Node.getTransformedBounds(Node.java:3403)
    at javafx.scene.Node.updateBounds(Node.java:538)
    at javafx.scene.Parent.updateBounds(Parent.java:1711)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Parent.updateBounds(Parent.java:1709)
    at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2404)
    at com.sun.javafx.tk.Toolkit.lambda$runPulse$31(Toolkit.java:348)
    at com.sun.javafx.tk.Toolkit$$Lambda$167/1784277725.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.Toolkit.runPulse(Toolkit.java:347)
    at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:374)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:510)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:490)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$405(QuantumToolkit.java:319)
    at com.sun.javafx.tk.quantum.QuantumToolkit$$Lambda$51/396808120.run(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$null$50(GtkApplication.java:139)
    at com.sun.glass.ui.gtk.GtkApplication$$Lambda$47/1609034571.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
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
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException
Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException

先生,有任何要发表的代码吗? - Elltz
@Elltz 我有大约30个与JavaFX相关联的类。哪一个?我得说 - 我甚至都不知道看哪一个。 - Pavel_K
3
似乎你在布局过程中遇到了异常,所以每次都会发生异常。请创建一个最小可复现示例并发布它。否则很难找到问题的所在... - fabian
第一个异常与其他异常不同,并且似乎发生在某个“Text”节点上。如果您明确拥有“Text”节点,我会从那里开始检查。正如@fabian所指出的,这些异常发生在布局期间。即使您有大量的类,您可以假设独立于彼此显示由其中一小部分类表示的布局子集,因此您可以缩小异常的原因。 - James_D
请参考以下链接获取更多信息:https://dev59.com/c5ffa4cB1Zd3GeqP9o1M#45679685 - Wolfgang Fahl
显示剩余2条评论
1个回答

6

我也遇到过这个问题,想写一下我是如何解决的。答案是:我在非JavaFX线程中编辑了GUI。我绝对相信我没有这样做,但事实上我确实是这样做的。如果你遇到这个问题,请检查你的代码,使用 Platform.runLater() 在正确的JavaFX线程中运行GUI更改。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接