Here you can find the source of createIconButton(ImageIcon icon, int dimension, String tooltipText, java.awt.event.ActionListener action)
public static JButton createIconButton(ImageIcon icon, int dimension, String tooltipText, java.awt.event.ActionListener action)
//package com.java2s; //License from project: Open Source License import java.awt.Dimension; import java.awt.Insets; import javax.swing.ImageIcon; import javax.swing.JButton; public class Main { public static JButton createIconButton(ImageIcon icon, int dimension, String tooltipText, java.awt.event.ActionListener action) { JButton btn = new JButton(); btn.setToolTipText(tooltipText); btn.setIcon(icon);/* w w w.j av a2 s .co m*/ btn.setMaximumSize(new Dimension(dimension, dimension)); btn.setMinimumSize(new Dimension(dimension, dimension)); btn.setPreferredSize(new Dimension(dimension, dimension)); btn.setMargin(new Insets(0, 0, 0, 0)); if (action != null) btn.addActionListener(action); return btn; } }