Java JButton Create createToolBarToggleButton(ImageIcon ic, String toolTip, ActionListener al)

Here you can find the source of createToolBarToggleButton(ImageIcon ic, String toolTip, ActionListener al)

Description

create Tool Bar Toggle Button

License

Creative Commons License

Declaration

public static JToggleButton createToolBarToggleButton(ImageIcon ic,
            String toolTip, ActionListener al) 

Method Source Code

//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);
    }
}

Related

  1. createSquareButton(String text, int size)
  2. createStandartButton(String name)
  3. createToggleButton(ImageIcon icon, int dimension, String tooltipText, java.awt.event.ActionListener action)
  4. createToolBarButton(Action action)
  5. createToolBarButton(String text, Icon icon)
  6. createTransparentButton(Action action, boolean withText)
  7. getCreateButton()
  8. makeButton(Action action)
  9. makeButton(String name, ActionListener l)