Example usage for javax.swing JButton setSelectedIcon

List of usage examples for javax.swing JButton setSelectedIcon

Introduction

In this page you can find the example usage for javax.swing JButton setSelectedIcon.

Prototype

@BeanProperty(visualUpdate = true, description = "The selected icon for the button.")
public void setSelectedIcon(Icon selectedIcon) 

Source Link

Document

Sets the selected icon for the button.

Usage

From source file:org.revager.tools.GUITools.java

/**
 * Creates a new image button./*from  w  w w  .  j  ava 2 s .  c o m*/
 * 
 * @param icon
 *            the normal icon
 * @param rolloverIcon
 *            the rollover icon
 * @param action
 *            the action
 * 
 * @return the newly created image button
 */
public static JButton newImageButton(ImageIcon icon, ImageIcon rolloverIcon, Action action) {
    JButton button = new JButton(action);
    button.setToolTipText(button.getText());
    button.setText(null);
    button.setContentAreaFilled(false);
    button.setBorder(new EmptyBorder(0, 0, 0, 0));
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setBorderPainted(false);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.setFocusPainted(false);
    button.setFocusable(false);

    button.setIcon(icon);
    button.setRolloverIcon(rolloverIcon);
    button.setRolloverSelectedIcon(rolloverIcon);
    button.setSelectedIcon(rolloverIcon);
    return button;
}