Java JButton Settings setButton(AbstractButton button, Icon icon, ActionListener buttonListener)

Here you can find the source of setButton(AbstractButton button, Icon icon, ActionListener buttonListener)

Description

Set Button using given arguments.

License

Open Source License

Parameter

Parameter Description
button the button to set
icon the icon to be set to button
buttonListener the ActionListener to be set to button

Declaration

static final void setButton(AbstractButton button, Icon icon,
        ActionListener buttonListener) 

Method Source Code

//package com.java2s;
import java.awt.event.ActionListener;
import javax.swing.AbstractButton;
import javax.swing.Icon;

public class Main {
    /**//from   w  w w.  ja  va2 s  . co m
     * <p>
     * Set Button using given arguments.
     * </p>
     *
     * @param button
     *            the button to set
     * @param icon
     *            the icon to be set to button
     * @param buttonListener
     *            the ActionListener to be set to button
     */
    static final void setButton(AbstractButton button, Icon icon,
            ActionListener buttonListener) {
        // set icon or set invisible
        button.setIcon(icon);
        button.addActionListener(buttonListener);
        // set the content to not filled
        button.setContentAreaFilled(false);
    }
}

Related

  1. selectWithoutNotifyingListeners(AbstractButton ab, boolean selected)
  2. setAction(AbstractButton btn, ActionListener listener, String actionCommand)
  3. setAllEnabled(final ButtonGroup buttonGroup, final boolean enabled)
  4. setAutoMnemonic(AbstractButton button)
  5. setBtnValue(ButtonGroup group, String value)
  6. setButtonContentMargin(AbstractButton button, Insets margin)
  7. setButtonInsetsRecursive(Insets insets, Container container)
  8. setButtonSelected(ButtonGroup buttonGroup, int selected)
  9. setButtonStyle(AbstractButton btn)