Java JButton Create createSquareButton(String text, int size)

Here you can find the source of createSquareButton(String text, int size)

Description

Creates a new JButton that is perfectly square

License

Open Source License

Parameter

Parameter Description
text the text of the button
size the size of the button

Return

a new JButton

Declaration

public static JButton createSquareButton(String text, int size) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.*;
import javax.swing.*;

public class Main {
    /**/*from  w  w w. j  a  v  a 2 s  . co  m*/
     * Creates a new JButton that is perfectly square
     * @param text the text of the button
     * @param size the size of the button
     * @return a new JButton
     */
    public static JButton createSquareButton(String text, int size) {
        JButton button = new JButton(text);
        button.setPreferredSize(new Dimension(size, size));
        button.setMargin(new Insets(0, 0, 0, 0));

        return button;
    }
}

Related

  1. createRadioButtonGrouping(String elements[], String title)
  2. createScreenCaptureButton()
  3. createSimpleTextButton(String caption, Action action)
  4. createSmallButton()
  5. createSmallButton(Icon icon, String tooltip, ActionListener listener)
  6. createStandartButton(String name)
  7. createToggleButton(ImageIcon icon, int dimension, String tooltipText, java.awt.event.ActionListener action)
  8. createToolBarButton(Action action)
  9. createToolBarButton(String text, Icon icon)