基本上是抛出异常,我找不到原因。这是我在控制台上得到的:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0
at org.apache.batik.gvt.renderer.StrokingTextPainter.computeTextRuns(Unknown Source)
at org.apache.batik.gvt.renderer.StrokingTextPainter.getTextRuns(Unknown Source)
at org.apache.batik.gvt.renderer.StrokingTextPainter.getOutline(Unknown Source)
at org.apache.batik.gvt.renderer.BasicTextPainter.getGeometryBounds(Unknown Source)
at org.apache.batik.gvt.TextNode.getGeometryBounds(Unknown Source)
at org.apache.batik.gvt.TextNode.getSensitiveBounds(Unknown Source)
at org.apache.batik.gvt.AbstractGraphicsNode.getTransformedSensitiveBounds(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.getSensitiveBounds(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.getTransformedSensitiveBounds(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.getSensitiveBounds(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.getTransformedSensitiveBounds(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.getSensitiveBounds(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.getTransformedSensitiveBounds(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.getSensitiveBounds(Unknown Source)
at org.apache.batik.gvt.CompositeGraphicsNode.nodeHitAt(Unknown Source)
at org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchMouseEvent(Unknown Source)
at org.apache.batik.gvt.event.AbstractAWTEventDispatcher.dispatchEvent(Unknown Source)
at org.apache.batik.gvt.event.AWTEventDispatcher.dispatchEvent(Unknown Source)
at org.apache.batik.gvt.event.AbstractAWTEventDispatcher.mouseEntered(Unknown Source)
at org.apache.batik.swing.gvt.AbstractJGVTComponent$Listener.dispatchMouseEntered(Unknown Source)
at org.apache.batik.swing.svg.AbstractJSVGComponent$SVGListener.dispatchMouseEntered(Unknown Source)
at org.apache.batik.swing.gvt.AbstractJGVTComponent$Listener.mouseEntered(Unknown Source)
at java.awt.AWTEventMulticaster.mouseEntered(Unknown Source)
at java.awt.AWTEventMulticaster.mouseEntered(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.trackMouseEnterExit(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
它显然来自我用来绘制 SVG 文件的蜡染库,但我确保在文件加载、准备好并在屏幕上显示之前没有绘制任何内容。抛出时没有任何东西被绘制。
另一个有趣的事情是投掷的时机。我找不到任何合乎逻辑的模式,因为有时它会在我开始上课时立即抛出,有时需要超过五分钟。除此之外,据我测试,没有一个单独的动作调用 repaint() 来触发它,或者更确切地说是所有动作。
我是 Java 新手,所有其他异常都有抛出它们的类和行号,所以我不知道该怎么做。
任何建议将不胜感激。
代码是巨大的,所以我会只放paint方法,如果需要任何额外的东西,请说出来。
@Override
public void paint(Graphics g) {
if(documentLoaded && showingOnScreen){
try{
rad = (int)(radInit+zoom*faktorRad); //max rad = 20
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
paintElements(g2d);
}
catch(NullPointerException nulle){
}
}
}
编辑:我的班级没有数组,所以我无法检查任何索引。我认为这个异常是从我使用的库中抛出的,但它是一个 .jar 文件,我不知道如何打开它或者我是否可以打开它。