Java JToolBar makeToolButton(URL iconURL, String cmd, String tooltip, String alt, ActionListener listener)

Here you can find the source of makeToolButton(URL iconURL, String cmd, String tooltip, String alt, ActionListener listener)

Description

make Tool Button

License

Open Source License

Declaration

public static JButton makeToolButton(URL iconURL, String cmd, String tooltip, String alt,
            ActionListener listener) 

Method Source Code


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

Related

  1. getToolbarOrientation(String location)
  2. hideChildButtonsWithTooltip(Container parent, String tooltip)
  3. initIconButton(AbstractButton button, String toolTip)
  4. isToolBarButton(JComponent c)
  5. isToolBarButton(JComponent c)
  6. resizeToolBarButtons(JComponent toolbar)
  7. searchFakeToolBarRecursive(Container c)
  8. setToolIcons(AbstractButton b, Icon[] icons)
  9. setToolIcons(AbstractButton b, Icon[] icons)