Example usage for javax.swing JToggleButton setRolloverIcon

List of usage examples for javax.swing JToggleButton setRolloverIcon

Introduction

In this page you can find the example usage for javax.swing JToggleButton setRolloverIcon.

Prototype

@BeanProperty(visualUpdate = true, description = "The rollover icon for the button.")
public void setRolloverIcon(Icon rolloverIcon) 

Source Link

Document

Sets the rollover icon for the button.

Usage

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

private static void setupButton(JToggleButton button, String toolTipText, String rolloverImg,
        String selectedImg) {//from ww w . j  a  v a2 s. c o  m
    button.setFont(new Font("Dialog", Font.PLAIN, 12));
    button.setVerticalTextPosition(SwingConstants.BOTTOM);
    button.setHorizontalTextPosition(SwingConstants.CENTER);
    button.setText(toolTipText);
    button.setRolloverIcon(new ImageIcon(Constants.IMG_FOLDER + rolloverImg));
    button.setSelectedIcon(new ImageIcon(Constants.IMG_FOLDER + selectedImg));
    button.setBackground(m_selected_but_color);
    button.setToolTipText(toolTipText);

    // Remove border
    Border emptyBorder = BorderFactory.createEmptyBorder();
    button.setBorder(emptyBorder);
    // Set adequate size
    button.setPreferredSize(new Dimension(32, 32));
}

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

/**
 * Creates a new image toggle button.//from   ww  w . j  a  v  a  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 JToggleButton newImageToggleButton(ImageIcon icon, ImageIcon rolloverIcon, Action action) {
    JToggleButton button = new JToggleButton(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;
}