Here you can find the source of scaleAllAbstractButtonIconsOf(Container container, int size)
Parameter | Description |
---|---|
container | a container containing abstract buttons |
size | the size which should be used for the icons |
public static void scaleAllAbstractButtonIconsOf(Container container, int size)
//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)); } } } } }