title: Java GUI functionality - subclass issues?
body: <p>I am working on a program that outputs the shortest path between two artists (known by their integer IDs). Start and end are the used inputs for the two artists. I am creating a GUI with a run button and a label. When the button is pressed, the program should calculate a shortest path, which is then returned as a string and set as the label of the GUI. The shortest path would look something like this 5 73 19 100, where each of the ints are IDs of artists and 5 is the start artist and 100 is the end artist. </p>
  
  <p>My code for shortest path (the code in function()) works fine when I put it in main. However, when I try to combine get my GUI to run it, the final string only contains the first artist. It seems my da.run is no longer functional? Does this have something to do with the fact it is in another class?</p>
  
  <p>Any pointers about what might be happening would be appreciated. Here is all the relevant GUI code since I think that is where the problem is</p>
  
  <pre><code>public class ShortestPath extends JFrame {
  
  private static Map&lt;Integer, Artist&gt; artists = new HashMap&lt;Integer, Artist&gt;();
  private static Artist start, end;
  private static ArtistGraph map = new ArtistGraph(artists);
  private static DijkstrasAlgorithm da = new DijkstrasAlgorithm(map);
  private static Route r = new Route();
  
  private static Connection connection;
  private static Statement statement;
  
  private Container contentPane;
  private JPanel panel1, panel2;
  private JButton button1;
  private JLabel label1, label2, label3;
  private JTextField field1, field2;
  
  public ShortestPath() {
      //CODE FOR SETTING LABELS, PANELS, ETC REMOVED BECAUSE NOT RELEVANT FOR QUESTION
      button1.addActionListener(new Listener());
      panel1.add(button1);
  
      pack();
      setVisible(true);
  
  }
  
  private class Listener implements ActionListener
  {
      public void actionPerformed(ActionEvent e)  
      {
  
          start = generateArtist(field1.getText());
          end = generateArtist(field2.getText());
          String done = function();
  
  
          label3.setText(done);
  
  
      }
  }
  
   public static String function(){               
          ArtistGraph map = new ArtistGraph(artists);
          DijkstrasAlgorithm da = new DijkstrasAlgorithm(map);
          da.run(start, end);
  
          Route r = new Route();
          r.calculateRoute(end, da);
  
          for (int i = 0; i &lt; r.getRoute().size(); i++) {
              int artist_id = r.getRoute().get(i).getID();
              System.out.println(artist_id);
          }
  
          String s = r.toString();
  
          return s;
      }
  </code></pre>
  
  <p>Let me know if any other pieces of code would be useful. </p>