Arithmetic error whilst using JXMapKit

153 views Asked by At

I am trying to build a swing application that generates a map.

After a lot of research i found JXMapKit.

So, i created an application using the JXMapKit libraries found here: JXMapKit Libraries

Basically when i run the program i have created i get a java.lang.ArithmeticException: / by zero error and i cannot figure out why.

Here is my code:

Main Class:

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);
  }
}

frame class:

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);    
  }
}

Here is the entire stack trace as requested, when i click on one of the lines it says that line number doesn't exist:

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

There are 0 answers