基本上是抛出异常,我找不到原因。这是我在控制台上得到的内容:
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文件,我不知道如何打开它或者我是否可以。
答案 0 :(得分:0)
java.lang.ArrayIndexOutOfBoundsException
仅在使用非法索引访问数组时抛出此异常。索引为负数或大于或等于数组的大小。 ArrayIndexOutOfBoundsException。
这意味着在你的程序中某些地方以错误的方式使用数组。
答案 1 :(得分:0)
当库试图计算有关几何的某些内容时,似乎在“鼠标输入”事件之后抛出异常。堆栈跟踪中的所有类都不是您定义的侦听器。我担心我对这个库一无所知,但是我建议你浏览一下你为不太正确的东西定义的UI,或者甚至只是那些你可以删除并试图重现问题的东西。它看起来像渲染的几何体有问题,或者在它应该被调用之前被调用,并且依赖于尚未发生的渲染。