Java JButton Settings scaleAllAbstractButtonIconsOf(Container container, int size)

Here you can find the source of scaleAllAbstractButtonIconsOf(Container container, int size)

Description

Resizes the icons of all the abstract buttons which are contained in a container.

License

Open Source License

Parameter

Parameter Description
container a container containing abstract buttons
size the size which should be used for the icons

Declaration

public static void scaleAllAbstractButtonIconsOf(Container container, int size) 

Method Source Code


//package com.java2s;
/*/*from  ww w  .  j a v  a2s . com*/
 * Copyright 1997-2013 Fabien Michel, Olivier Gutknecht, Jacques Ferber
 * 
 * This file is part of MaDKit.
 * 
 * MaDKit 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 3 of the License, or
 * (at your option) any later version.
 * 
 * MaDKit 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
 * along with MaDKit. If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.Component;
import java.awt.Container;

import java.awt.Image;

import javax.swing.AbstractButton;

import javax.swing.ImageIcon;

public class Main {
    /**
     * Resizes the icons of all the abstract buttons which are contained in a
     * container.
     * 
     * @param container
     *            a container containing abstract buttons
     * @param size
     *            the size which should be used for the icons
     */
    public static void scaleAllAbstractButtonIconsOf(Container container, int size) {
        for (final Component c : container.getComponents()) {
            if (c instanceof AbstractButton) {
                final ImageIcon i = (ImageIcon) ((AbstractButton) c).getIcon();
                if (i != null) {
                    i.setImage(i.getImage().getScaledInstance(size, size, Image.SCALE_SMOOTH));
                }
            }
        }
    }
}

Related

  1. parseLevel(ButtonGroup buttonGroup)
  2. removeAllActionListeners(AbstractButton btn)
  3. removeButtonBorder(AbstractButton button)
  4. removeCloseButton(Component comp)
  5. removeListeners(AbstractButton button)
  6. scaleButtonIcon(Icon icon, int size)
  7. ScaleButtonIcon(JToggleButton btn, int width, int height, int fontsize)
  8. SelectedOptionButton(Container container)
  9. selectFile(final int openMode, final String title, final String buttonText, final String lastDirectoryUsed, final Component parent, final String suffix, final String description)