Java tutorial
//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); } 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; } }