clickable markers in JMapViewer?


I’m extending GPXCreator ( with new functionality. currently I’m struggling to implement clickable markers to be used with JMapViewer. for some reasons, I don’t want to go though all markers and check if one of them is at the location of the mouseclick.

therefore I try to add a JLabel to JMapViewer, but with strange results.

protected void paintComponent(Graphics g) {
Waypoint wpt = seg.getWaypoints().get(i);
Point point = mapPanel.getMapPosition(wpt.getLat(), wpt.getLon(), false);
JLabel label = new JLabel();


  • the markers (aka JLabels) don’t show up directly after painting, but after some random(?) time.
  • if label.repaint() is called, the labels show up immediately (for most of the time), but then PaintComponents() seems to be called recursively in an endless loop.
  • even then, sometimes they don’t show up.

andy ideas?

thanks in advance.