public void actionPerformed(ActionEvent e) {
    if (e.getSource().equals(genPoints)) {
      int w = graphPanel.getWidth();
      int h = graphPanel.getHeight();
      pRadius = Utils.scaledPointSize(numPoints, w, h);
      myGraph.reset();
      resetPath();
      myGraph.addNodes(Utils.genPoints(numPoints, w, h), w, h);
      repaint();
    }
    else if (e.getSource().equals(genMstSlow)) {
      myGraph.genMSTSlow();
      repaint();
    }
    else if (e.getSource().equals(genMstFast)) {
      myGraph.genMSTFast();
      repaint();
    }
    else if (e.getSource().equals(pointsField)) {
      String new_points = pointsField.getText();
      try {
        int num = Integer.parseInt(new_points);
        genPoints.setText("Generate " + num + " random nodes");
        numPoints = num;
      } catch (Exception exc) {
        System.out.println("Please enter a positive integer!");
      }
    }
  }