Java JButton copyButtonWidth(JButton toButton, JButton fromButton)

Here you can find the source of copyButtonWidth(JButton toButton, JButton fromButton)

Description

Makes a button as wide as another given button.

License

GNU General Public License

Parameter

Parameter Description
toButton The button that will take on the width of another
fromButton The button whose width will be copied

Declaration

public static void copyButtonWidth(JButton toButton, JButton fromButton) 

Method Source Code

//package com.java2s;
/*//from w  ww  .j  a v  a  2  s .  co m
 * (C) Copyright 2009-2011  Cristian Dinu <goc9000@gmail.com>
 * 
 * Licensed under the GPL-3.
 */

import javax.swing.JButton;

public class Main {
    /**
     * Makes a button as wide as another given button. This is
     * useful for making sure buttons arranged in a column have the
     * same width.
     * 
     * @param toButton The button that will take on the width of another
     * @param fromButton The button whose width will be copied
     */
    public static void copyButtonWidth(JButton toButton, JButton fromButton) {
        toButton.setPreferredSize(fromButton.getPreferredSize());
        toButton.setMaximumSize(fromButton.getMaximumSize());
    }
}

Related

  1. btnHover(JButton btn)
  2. buttonState(JButton button, boolean boolArrayOfErrors[])
  3. closeFrame(JButton thisButton)
  4. configureButton(JButton button)
  5. considerarSetaComoTab(JButton comp)
  6. doButtonClick(JButton button)
  7. drawCharacter(JPanel contentPane, ActionListener listener, String url, int x, int y, List buttons)
  8. enableEnter(JButton b)
  9. ensureButtonWidth(JButton button, int width)