Java JButton Size setSizes(JButton[] aButtons, Dimension aPreferred, Dimension aMax)

Here you can find the source of setSizes(JButton[] aButtons, Dimension aPreferred, Dimension aMax)

Description

Sets the preferred and maximum sizes of the given buttons.

License

Open Source License

Parameter

Parameter Description
aButtons Buttons to be modified.
aPreferred Preferred size to be set to each of the buttons. If this is <code>null</code>, every button's preferred size is set to its default value.
aMax Maximum size to be set to each of the buttons. If this is <code>null</code>, every button's maximum size is set to its default value.

Exception

Parameter Description
NullPointerException If <code>aButtons</code> is <code>null</code>.

Declaration

public static void setSizes(JButton[] aButtons, Dimension aPreferred, Dimension aMax) 

Method Source Code

//package com.java2s;
/*/* w ww.  ja v a 2  s .  c o  m*/
 * Copyright (c) 2006, 2007, 2008, 2010, Max Planck Institute for Informatics, Saarbruecken, Germany.
 *
 * This file is part of NetworkAnalyzer.
 * 
 * NetworkAnalyzer is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 * 
 * NetworkAnalyzer 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 Lesser General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with NetworkAnalyzer. If not, see
 * <http://www.gnu.org/licenses/>.
 */

import java.awt.Dimension;

import javax.swing.JButton;

public class Main {
    /**
     * Sets the preferred and maximum sizes of the given buttons.
     * 
     * @param aButtons
     *            Buttons to be modified.
     * @param aPreferred
     *            Preferred size to be set to each of the buttons. If this is <code>null</code>, every
     *            button's preferred size is set to its default value.
     * @param aMax
     *            Maximum size to be set to each of the buttons. If this is <code>null</code>, every button's
     *            maximum size is set to its default value.
     * 
     * @throws NullPointerException
     *             If <code>aButtons</code> is <code>null</code>.
     */
    public static void setSizes(JButton[] aButtons, Dimension aPreferred, Dimension aMax) {
        for (final JButton button : aButtons) {
            button.setPreferredSize(aPreferred);
            button.setMaximumSize(aMax);
        }
    }
}

Related

  1. ScaleButtonIcon(javax.swing.JButton btn, int width, int height, int fontsize)
  2. setButtonSize(JButton button, Dimension size)
  3. setButtonSize(JButton button, int width, int height)
  4. setJButtonSizesTheSame(final JButton[] btns)
  5. setJButtonSizesTheSame(JButton[] btns)
  6. SetStandardSizeForButton(JButton btn)