I am trying to learn JMapViewer
, and have a map embedded in a JPanel
, which is a part of CardLayout
. At this point, I only want to display a map without zoom, mouse action listeners, etc. So, I created a GUI frame in NetBeans with CardLayout
and a number of JPanel
s. Inside one of the panels, I have added another panel where the map should be located. Then I added JMapViewer.jar
and JMapViewer_src.jar
. Then I added the following simple code:
package viewController;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import org.openstreetmap.gui.jmapviewer.JMapViewer;
import org.openstreetmap.gui.jmapviewer.events.JMVCommandEvent;
import org.openstreetmap.gui.jmapviewer.interfaces.JMapViewerEventListener;
public class PanelAcars extends javax.swing.JPanel implements JMapViewerEventListener
{
public PanelAcars()
{
super();
setSize(400,400);
initComponents();
final JMapViewer map = new JMapViewer();
pnlAcarsMapView.add(map);
}
@Override
public void processCommand(JMVCommandEvent command) {
if (command.getCommand().equals(JMVCommandEvent.COMMAND.ZOOM) ||
command.getCommand().equals(JMVCommandEvent.COMMAND.MOVE)) {
//updateZoomParameters();
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
pnlAcarsMapView = new javax.swing.JPanel();
...
}
private javax.swing.JPanel pnlAcarsMapView;
}
The panel is empty. I have the Demo.java
code and it works if I simply copy and paste it in a new project. But I would like to modify it starting from building a simple map and adding it to my panel. What am I missing?
Thank you!