Here you can find the source of addButtonToPanel(JPanel panel, Object constraints, String text)
Parameter | Description |
---|---|
panel | The panel to add the button to. |
constraints | The constraints of the button. |
text | The button text. |
public static JButton addButtonToPanel(JPanel panel, Object constraints, String text)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import javax.swing.JButton; import javax.swing.JPanel; public class Main { public static final Color BACKGROUND = new Color(245, 245, 245); /**/*from w ww .j a va2 s . com*/ * Adds a button to a panel. * @param panel The panel to add the button to. * @param constraints The constraints of the button. * @param text The button text. * @return The created button. */ public static JButton addButtonToPanel(JPanel panel, Object constraints, String text) { JButton button = new JButton(text); button.setBackground(BACKGROUND); panel.add(button, constraints); return button; } }