Here you can find the source of makeToolButton(URL iconURL, String cmd, String tooltip, String alt, ActionListener listener)
public static JButton makeToolButton(URL iconURL, String cmd, String tooltip, String alt, ActionListener listener)
//package com.java2s; import java.awt.event.ActionListener; import java.net.URL; import javax.swing.ImageIcon; import javax.swing.JButton; public class Main { public static JButton makeToolButton(URL iconURL, String cmd, String tooltip, String alt, ActionListener listener) { JButton button = new JButton(); button.setActionCommand(cmd);/* w ww. j a v a 2 s .c o m*/ button.setToolTipText(tooltip); button.addActionListener(listener); if (iconURL != null) { button.setIcon(new ImageIcon(iconURL, alt)); } else { //no image found button.setText(alt); } return button; } }