public int getIndexTo(){
    int numOfOptions=_map.mygraph.getCurr();
    if(numOfOptions==0){
      JOptionPane.showMessageDialog(null,"There isn't any location on the map!",
                                    "Choose the end point",JOptionPane.ERROR_MESSAGE,null);
      return -1; 
    }
    String[] options=new String[numOfOptions];
    for(int i=0;i<numOfOptions;i++){
      options[i]=i+": ID:"+_map.mygraph.locations[i].getID()+" Name:"+_map.mygraph.locations[i].getName(); 
    }
    String s=(String)JOptionPane.showInputDialog(null,"Choose a location to end at:","Find",
                                                 JOptionPane.PLAIN_MESSAGE,null,options,options[0]);
    if(s==null){
      return -1; 
    }
    int index=0;
    for(int i=0;s.charAt(i)!=':';i++){
      index=10*index+(s.charAt(i)-'0');
    }
    return index;
  }