Here you can find the source of createToolBarToggleButton(ImageIcon ic, String toolTip, ActionListener al)
public static JToggleButton createToolBarToggleButton(ImageIcon ic, String toolTip, ActionListener al)
//package com.java2s; //License from project: Creative Commons License import java.awt.Insets; import java.awt.event.ActionListener; import javax.swing.AbstractButton; import javax.swing.ImageIcon; import javax.swing.JToggleButton; public class Main { private static final Insets ZERO_INSETS = new Insets(0, 0, 0, 0); public static JToggleButton createToolBarToggleButton(ImageIcon ic, String toolTip, ActionListener al) { JToggleButton button = new JToggleButton(ic); fixButton(button, toolTip);//from ww w .j a v a 2s . c o m if (al != null) button.addActionListener(al); return button; } private static void fixButton(AbstractButton button, String toolTip) { button.setFocusable(false); button.setMargin(ZERO_INSETS); button.setToolTipText(toolTip); } }