Java JButton Create newButton(String text, ActionListener... listeners)

Here you can find the source of newButton(String text, ActionListener... listeners)

Description

new Button

License

Open Source License

Declaration

static Component newButton(String text, ActionListener... listeners) 

Method Source Code


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

import java.awt.Component;

import java.awt.event.ActionListener;

import javax.swing.JButton;

public class Main {
    static Component newButton(String text, ActionListener... listeners) {
        return newButton(text, null, listeners);
    }/* w w  w. jav  a  2s.  com*/

    static Component newButton(String text, String actionCommand, ActionListener... listeners) {
        JButton button = new JButton(text);
        button.setActionCommand(actionCommand);
        for (ActionListener l : listeners)
            button.addActionListener(l);

        return button;
    }
}

Related

  1. makeIconButton(Icon icon, String tooltip)
  2. makeNavigationButton(String actionCommand, String toolTipText, String altText)
  3. makeRadioButton(String text, String actionCommand, ButtonGroup buttonGroup, boolean selected)
  4. makeToggleButton(final Object owner, final String id, final String altText, final int wpad, final int hpad)
  5. newButton(String name, String text)
  6. newButtonPopup(final JToggleButton button)
  7. newButtonsFrom(Collection action)
  8. newJButton()
  9. newJButton(String name, String tooltip, ActionListener al)