]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/gui/WaypointListModel.java
Version 16, February 2014
[GpsPrune.git] / tim / prune / gui / WaypointListModel.java
index e5b41865e739a0cb08dc95382fc82eb692472ffd..3d5dd1fb62bafaa222df382109ead68756ad0605 100644 (file)
@@ -9,7 +9,7 @@ import tim.prune.data.Track;
 /**
  * Class to act as list model for the waypoint list
  */
-public class WaypointListModel extends AbstractListModel
+public class WaypointListModel extends AbstractListModel<String>
 {
        Track _track = null;
        ArrayList<DataPoint> _waypoints = null;
@@ -36,10 +36,13 @@ public class WaypointListModel extends AbstractListModel
        /**
         * @see javax.swing.ListModel#getElementAt(int)
         */
-       public Object getElementAt(int inIndex)
+       public String getElementAt(int inIndex)
        {
-               if (inIndex < 0 || inIndex >= getSize()) return "";
-               return _waypoints.get(inIndex).getWaypointName();
+               DataPoint p = null;
+               if (inIndex < 0 || inIndex >= getSize()
+                       || _waypoints == null || (p = _waypoints.get(inIndex)) == null)
+                       return "";
+               return p.getWaypointName();
        }
 
        /**