Here you can find the source of createSquareButton(String text, int size)
Parameter | Description |
---|---|
text | the text of the button |
size | the size of the button |
public static JButton createSquareButton(String text, int size)
//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; } }