code: private JButton makeButton(String imageName, String actionCommand, String toolTipText, String altText) {
          //Look for the image.
          String imgLocation = "images/" + imageName + "16.png";
          URL imageURL = PlotCanvas.class.getResource(imgLocation);
  
          //Create and initialize the button.
          JButton button = new JButton();
          button.setActionCommand(actionCommand);
          button.setToolTipText(toolTipText);
          button.addActionListener(this);
  
          if (imageURL != null) {                      //image found
              button.setIcon(new ImageIcon(imageURL, altText));
          } else {                                     //no image found
              button.setText(altText);
              logger.error("Resource not found: {}", imgLocation);
          }
  
          return button;
      }
docs: Creates a button for toolbar.