Here you can find the source of createButton(ImageIcon icon, String text)
public static JButton createButton(ImageIcon icon, String text)
//package com.java2s; //License from project: Open Source License import javax.swing.*; public class Main { /** @return A JButton in which the text is shown if the icon is null */ public static JButton createButton(ImageIcon icon, String text) { JButton toret;// w w w. j ava2s. c o m if (icon != null) { toret = new JButton(icon); } else { toret = new JButton(text); } toret.setToolTipText(text); return toret; } }