Here you can find the source of addButton(ActionListener l, Container container, String name, String cmd)
Parameter | Description |
---|---|
l | the listener. |
container | the container. |
name | the button name. |
cmd | the action command. |
public static void addButton(ActionListener l, Container container, String name, String cmd)
//package com.java2s; // under the terms of the GNU Lesser General Public License as published import java.awt.Container; import java.awt.event.ActionListener; import javax.swing.JButton; public class Main { /**/*from ww w . j av a 2s . c o m*/ * Add a button to a container with the given parameters and * action listener. * * @param l the listener. * @param container the container. * @param name the button name. * @param cmd the action command. */ public static void addButton(ActionListener l, Container container, String name, String cmd) { JButton button = new JButton(name); button.addActionListener(l); button.setActionCommand(cmd); container.add(button); } }