Here you can find the source of createJButton(String text, String name, ActionListener a)
Parameter | Description |
---|---|
text | The label for the button. |
name | The name for the button. |
a | An ActionListener for action performing. |
public static JButton createJButton(String text, String name, ActionListener a)
//package com.java2s; //License from project: Open Source License import java.awt.event.ActionListener; import javax.swing.JButton; public class Main { /**//from w w w .j a v a2 s .c o m * Creates a {@link JButton} with a given text, a given name and a given * ActionListener. * * @param text The label for the button. * @param name The name for the button. * @param a An ActionListener for action performing. * @return The created {@link JButton}. */ public static JButton createJButton(String text, String name, ActionListener a) { JButton jb = new JButton(text); jb.setName(name); jb.addActionListener(a); return jb; } /** * Creates a {@link Button} with a given label used as name and an * ActionListener. * * @param text The name and label for the button. * @param a An ActionListener for action performing. * @return The created {@link Button}. */ public static JButton createJButton(String text, ActionListener a) { return createJButton(text, text, a); } }