使用JXMapKit时算术错误

时间:2014-10-22 23:55:18

标签: java swing jxmapkit

我正在尝试构建一个生成地图的swing应用程序。

经过大量研究后,我找到了JXMapKit。

所以,我使用这里找到的JXMapKit库创建了一个应用程序:JXMapKit Libraries

基本上当我运行我创建的程序时,我得到一个java.lang.ArithmeticException:/由零错误,我无法弄清楚原因。

这是我的代码:

主类:

import javax.swing.JFrame;

public class main {

  public static void main(String[] args) {
    frame f = new frame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(500,500);
    f.setResizable(false);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
  }
}

框架类:

import javax.swing.*;
import java.awt.BorderLayout;
import org.jdesktop.swingx.JXMapKit;

public class frame extends JFrame {

  JPanel panel;

  public frame(){
    super("Map Test");

    panel = new JPanel();
    panel.setLayout(new BorderLayout());
    add(panel);

    JXMapKit kit = new JXMapKit();
    kit.setDefaultProvider(JXMapKit.DefaultProviders.OpenStreetMaps);
    panel.add(kit, BorderLayout.CENTER);    
  }
}

这是请求的整个堆栈跟踪,当我点击其中一行时,它表示行号不存在:

Exception in thread "AWT-EventQueue-0" java.lang.ArithmeticException: / by zero
at org.jdesktop.swingx.mapviewer.AbstractTileFactory.getTile(AbstractTileFactory.java:82)
at org.jdesktop.swingx.mapviewer.AbstractTileFactory.getTile(AbstractTileFactory.java:72)
at org.jdesktop.swingx.JXMapViewer.drawMapTiles(JXMapViewer.java:254)
at org.jdesktop.swingx.JXMapViewer.doPaintComponent(JXMapViewer.java:193)
at org.jdesktop.swingx.JXMapViewer.access$300(JXMapViewer.java:68)
at org.jdesktop.swingx.JXMapViewer$1.doPaint(JXMapViewer.java:176)
at org.jdesktop.swingx.JXMapViewer$1.doPaint(JXMapViewer.java:174)
at org.jdesktop.swingx.painter.AbstractPainter.paint(AbstractPainter.java:435)
at org.jdesktop.swingx.JXPanel.paintComponent(JXPanel.java:638)
at javax.swing.JComponent.paint(JComponent.java:1054)
at org.jdesktop.swingx.JXPanel.paint(JXPanel.java:580)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at org.jdesktop.swingx.JXPanel.paint(JXPanel.java:580)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5228)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1482)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1413)
at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
at javax.swing.JComponent.paint(JComponent.java:1040)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
at java.awt.Container.paint(Container.java:1967)
at java.awt.Window.paint(Window.java:3877)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:781)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:721)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:691)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

0 个答案:

没有答案