In Java Swing, whenever you want to have components react to a click event on a button, you need to attach those components to an ActionListener, then pass the ActionListener object. Learn how to do all that right here.