Java JButton fixButtonWidth(JButton... buttons)

Here you can find the source of fixButtonWidth(JButton... buttons)

Description

fix Button Width

License

Open Source License

Declaration

public static void fixButtonWidth(JButton... buttons) 

Method Source Code


//package com.java2s;

import java.awt.Dimension;

import javax.swing.JButton;

public class Main {
    public static void fixButtonWidth(JButton... buttons) {
        fixButtonWidth(0, buttons);//www. j  av a2s.  c o m
    }

    public static void fixButtonWidth(int padding, JButton... buttons) {
        Dimension d = new Dimension();
        for (JButton b : buttons) {
            Dimension size = b.getPreferredSize();
            d.width = Math.max(size.width, d.width);
            d.height = Math.max(size.height, d.height);
        }
        d.width += 2 * padding;
        for (JButton b : buttons) {
            b.setPreferredSize(d);
        }
    }
}

Related

  1. enableEnter(JButton b)
  2. ensureButtonWidth(JButton button, int width)
  3. enterPressesWhenFocused(final JButton button)
  4. equalizeButtons(JButton... buttons)
  5. exit(JButton aButton)
  6. fixToolbarButtonImpl(JButton button)
  7. formatButtonAsLabel(JButton button)
  8. formatJButton(JButton button, String tooltips)
  9. getButtonNumber(JButton btn)