Java JToolBar setToolIcons(AbstractButton b, Icon[] icons)

Here you can find the source of setToolIcons(AbstractButton b, Icon[] icons)

Description

Change the Icons of an AbstractButton (JButton or JToggleButton).

License

Open Source License

Parameter

Parameter Description
b the button whose icons are to be set
icons four <code>Icon</code> objects for different gadget states, such as created by the <code>createToolIcons</code> method.

Declaration

public static void setToolIcons(AbstractButton b, Icon[] icons) 

Method Source Code


//package com.java2s;
/*//from  ww w. java2  s.c o  m
 *  GraphicsUtil.java
 *  Inertia
 *
 *  Copyright (c) 2004-2005 Hanns Holger Rutz. All rights reserved.
 *
 *   This software is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation; either
 *   version 2, june 1991 of the License, or (at your option) any later version.
 *
 *   This software is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *   General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public
 *   License (gpl.txt) along with this software; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *
 *   For further information, please contact Hanns Holger Rutz at
 *   contact@sciss.de
 *
 *
 *  Changelog:
 *      07-Aug-05   copied from de.sciss.eisenkraut.gui.GraphicsUtil
 */

import java.awt.*;

import javax.swing.*;

public class Main {
    /**
     *  Change the <code>Icon</code>s of an
     *  <code>AbstractButton</code> (<code>JButton</code>
     *  or <code>JToggleButton</code>).
     *
     *  @param  b      the button whose icons are to be set
     *  @param  icons   four <code>Icon</code> objects for
     *               different gadget states, such as
     *               created by the <code>createToolIcons</code> method.
     *
     *  @see   #createToolIcons( int )
     */
    public static void setToolIcons(AbstractButton b, Icon[] icons) {
        b.setIcon(icons[0]);
        b.setSelectedIcon(icons[1]);
        b.setPressedIcon(icons[3]);
        b.setDisabledIcon(icons[2]);
        Insets defInsets = b.getInsets();
    }
}

Related

  1. isToolBarButton(JComponent c)
  2. makeToolButton(URL iconURL, String cmd, String tooltip, String alt, ActionListener listener)
  3. resizeToolBarButtons(JComponent toolbar)
  4. searchFakeToolBarRecursive(Container c)
  5. setToolIcons(AbstractButton b, Icon[] icons)
  6. showTextOnToolbar(javax.swing.JToolBar t, boolean show)
  7. styleToolBarButton(final AbstractButton btn, final Font font, final boolean addPadding)