Java Code Examples for javax.swing.AbstractButton#setRolloverIcon()

The following examples show how to use javax.swing.AbstractButton#setRolloverIcon() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NavigationButtons.java    From pumpernickel with MIT License 5 votes vote down vote up
public static void formatPrev(AbstractButton button) {
	button.setIcon(createIcon(false, .75f));
	button.setRolloverIcon(createIcon(false, .85f));
	button.setSelectedIcon(createIcon(false, 1f));
	button.setDisabledIcon(createIcon(false, .3f));
	button.setUI(new BevelButtonUI());
	button.setContentAreaFilled(true);
	button.putClientProperty("JButton.segmentPosition", "first");
	button.setBorderPainted(true);
}
 
Example 2
Source File: NavigationButtons.java    From pumpernickel with MIT License 5 votes vote down vote up
public static void formatNext(AbstractButton button) {
	button.setIcon(createIcon(true, .75f));
	button.setRolloverIcon(createIcon(true, .85f));
	button.setSelectedIcon(createIcon(true, 1f));
	button.setDisabledIcon(createIcon(true, .3f));
	button.setUI(new BevelButtonUI());
	button.setContentAreaFilled(true);
	button.putClientProperty("JButton.segmentPosition", "last");
	button.setBorderPainted(true);
}
 
Example 3
Source File: LargeNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected Component createPreviousButton() {
	AbstractButton button = NavigationButtons.createPrev();
	format(button);
	button.setIcon(new TriangleIcon(SwingConstants.WEST, 24, 24,
			Color.lightGray));
	button.setRolloverIcon(new TriangleIcon(SwingConstants.WEST, 24, 24,
			Color.white));
	button.setDisabledIcon(new TriangleIcon(SwingConstants.WEST, 24, 24,
			Color.darkGray));
	button.setName(PREV_BUTTON_NAME);
	installPreviousButtonListeners(button);
	return button;
}
 
Example 4
Source File: LargeNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
protected Component createNextButton() {
	AbstractButton button = NavigationButtons.createNext();
	format(button);
	button.setIcon(new TriangleIcon(SwingConstants.EAST, 24, 24,
			Color.lightGray));
	button.setRolloverIcon(new TriangleIcon(SwingConstants.EAST, 24, 24,
			Color.white));
	button.setDisabledIcon(new TriangleIcon(SwingConstants.EAST, 24, 24,
			Color.darkGray));
	button.setName(NEXT_BUTTON_NAME);
	installNextButtonListeners(button);
	return button;
}
 
Example 5
Source File: LargeNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
protected AbstractButton createFirstButton() {
	AbstractButton button = new JButton();
	format(button);
	button.setIcon(new FirstIcon(2, 24, 24, Color.lightGray));
	button.setRolloverIcon(new FirstIcon(2, 24, 24, Color.white));
	button.setDisabledIcon(new FirstIcon(2, 24, 24, Color.darkGray));
	button.setName("Spinner.firstButton");
	installFirstButtonListeners(button);
	return button;
}
 
Example 6
Source File: LargeNavigationPanelUI.java    From pumpernickel with MIT License 5 votes vote down vote up
protected AbstractButton createLastButton() {
	AbstractButton button = new JButton();
	format(button);
	button.setIcon(new LastIcon(2, 24, 24, Color.lightGray));
	button.setRolloverIcon(new LastIcon(2, 24, 24, Color.white));
	button.setDisabledIcon(new LastIcon(2, 24, 24, Color.darkGray));
	button.setName("Spinner.lastButton");
	installLastButtonListeners(button);
	return button;
}
 
Example 7
Source File: TGToolBar.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
private AbstractButton getImageButton( AbstractButton button, String iconPrefix, String iconSuffix ){
	button.setHorizontalTextPosition(JButton.CENTER);
	button.setVerticalTextPosition(JButton.CENTER);
	button.setBorderPainted( false );
	button.setContentAreaFilled( false );
	button.setFocusPainted( false );
	button.setMargin( new Insets(0,0,0,0) );
	button.setIcon( TGResourceUtils.loadIcon( iconPrefix + iconSuffix ) );
	button.setPressedIcon( TGResourceUtils.loadIcon( iconPrefix + "_pressed" + iconSuffix ) );
	button.setRolloverIcon( TGResourceUtils.loadIcon( iconPrefix + "_over" + iconSuffix ) );
	button.setSelectedIcon( TGResourceUtils.loadIcon( iconPrefix + "_selected" + iconSuffix ) );
	button.setRolloverSelectedIcon( TGResourceUtils.loadIcon( iconPrefix + "_selected_over" + iconSuffix ) );
	return button;
}
 
Example 8
Source File: BETitlePane.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * 为按钮设置图标,并据原图icon自动调用方法 {@link #filterWithRescaleOp(ImageIcon, float, float, float, float)}
 * 使用滤镜分别生成RolloverIcon、PressedIcon并设置之.
 * 
 * @param btn
 * @param ico
 * @since 3.5
 * @deprecated since 3.6
 */
public static void setButtonIcon(AbstractButton btn, Icon ico)
{
	//* 图片设定
	btn.setIcon(ico);
	if(ico != null && ico instanceof ImageIcon)
	{
		//rover时图片颜色变成红色
		btn.setRolloverIcon(BEUtils.filterWithRescaleOp((ImageIcon)ico, 2f, 1f, 1f, 1f));
		//press时图片颜色变成淡红色
		btn.setPressedIcon(BEUtils.filterWithRescaleOp((ImageIcon)ico, 2f, 1f, 1f, 0.5f));
	}
}
 
Example 9
Source File: SpectrumChooser.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    final Object source = e.getSource();
    if (source instanceof AbstractButton) {
        AbstractButton collapseButton = (AbstractButton) source;
        toggleCollapsed(index);
        if (collapsed[index]) {
            collapseButton.setIcon(icons[0]);
            collapseButton.setRolloverIcon(roll_over_icons[0]);
        } else {
            collapseButton.setIcon(icons[1]);
            collapseButton.setRolloverIcon(roll_over_icons[1]);
        }
    }
}
 
Example 10
Source File: ToolButtonFactory.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static void configure(AbstractButton button) {

        RolloverButtonEventListener l = new RolloverButtonEventListener();
        button.addMouseListener(l);
        button.addItemListener(l);

        if (button.getAction() != null) {
            if (button.getIcon() != null) {
                button.putClientProperty("hideActionText", Boolean.TRUE);
            }
            Object largeIcon = button.getAction().getValue("_largeIcon");
            if (largeIcon instanceof Icon) {
                button.setIcon((Icon) largeIcon);
            }
        }

        Icon icon = button.getIcon();
        int minWidth = BUTTON_MIN_SIZE;
        int minHeight = BUTTON_MIN_SIZE;
        if (icon != null) {
            button.setText(null);
            minWidth = Math.max(icon.getIconWidth(), BUTTON_MIN_SIZE);
            minHeight = Math.max(icon.getIconHeight(), BUTTON_MIN_SIZE);
            if (icon instanceof ImageIcon) {
                button.setRolloverIcon(createRolloverIcon((ImageIcon) icon));
            }
        } else {
            button.setText("[?]");
        }
        final int space = 3;
        Dimension prefSize = new Dimension(minWidth + space, minHeight + space);
        Dimension minSize = new Dimension(minWidth, minHeight);
        Dimension maxSize = new Dimension(minWidth + space, minHeight + space);
        button.setPreferredSize(prefSize);
        button.setMaximumSize(maxSize);
        button.setMinimumSize(minSize);

    }
 
Example 11
Source File: TitledPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JComponent getCollapseButton(JComponent bodyComponent, boolean isInitiallyCollapsed) {
    final AbstractButton hideAndShowButton;
    if (isInitiallyCollapsed) {
        hideAndShowButton = ToolButtonFactory.createButton(CollapseSupport.expandIcon, false);
        hideAndShowButton.setRolloverIcon(CollapseSupport.expandRolloverIcon);
        hideAndShowButton.setToolTipText("Expand Panel");
    } else {
        hideAndShowButton = ToolButtonFactory.createButton(CollapseSupport.collapseIcon, false);
        hideAndShowButton.setRolloverIcon(CollapseSupport.collapseRolloverIcon);
        hideAndShowButton.setToolTipText("Collapse Panel");
    }
    hideAndShowButton.addActionListener(new CollapseSupport(isInitiallyCollapsed, bodyComponent, hideAndShowButton));

    return hideAndShowButton;
}
 
Example 12
Source File: EditorActionUtilities.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static void updateButtonIcons(AbstractButton button, Icon icon, boolean useLargeIcon, String iconResource) {
    button.setIcon(icon);

    if (iconResource != null) {
        String base = iconResource;
        String suffix = "";
        int dotIndex;
        if ((dotIndex = iconResource.lastIndexOf('.')) >= 0) {
            suffix = iconResource.substring(dotIndex, iconResource.length());
            base = iconResource.substring(0, dotIndex);
        }
        if (useLargeIcon) {
            base += LARGE_ICON_SIZE_STRING;
        }

        Icon pressedIcon = ImageUtilities.loadImageIcon(base + "_pressed" + suffix, true); // NOI18N
        if (pressedIcon != null) {
            button.setPressedIcon(pressedIcon);
        }
        Icon rolloverIcon = ImageUtilities.loadImageIcon(base + "_rollover" + suffix, true); // NOI18N
        if (rolloverIcon != null) {
            button.setRolloverIcon(rolloverIcon);
        }
        Icon disabledIcon = ImageUtilities.loadImageIcon(base + "_disabled" + suffix, true); // NOI18N
        if (disabledIcon != null) {
            button.setDisabledIcon(disabledIcon);
        } else { // Make disabled icon from regular icon
            button.setDisabledIcon(ImageUtilities.createDisabledIcon(icon));
        }
        Icon selectedIcon = ImageUtilities.loadImageIcon(base + "_selected" + suffix, true); // NOI18N
        if (selectedIcon != null) {
            button.setSelectedIcon(selectedIcon);
        }
        Icon rolloverSelectedIcon = ImageUtilities.loadImageIcon(base + "_rolloverSelected" + suffix, true); // NOI18N
        if (rolloverSelectedIcon != null) {
            button.setRolloverSelectedIcon(rolloverSelectedIcon);
        }
        Icon disabledSelectedIcon = ImageUtilities.loadImageIcon(base + "_disabledSelected" + suffix, true); // NOI18N
        if (disabledSelectedIcon != null) {
            button.setDisabledSelectedIcon(disabledSelectedIcon);
        }
    }
}
 
Example 13
Source File: AnimationController.java    From pumpernickel with MIT License 4 votes vote down vote up
void setIcon(AbstractButton button, Icon icon) {
	button.setIcon(icon);
	button.setRolloverIcon(new DarkenedIcon(button, .5f));
	button.setPressedIcon(new DarkenedIcon(button, .75f));
}
 
Example 14
Source File: BasicAudioPlayerUI.java    From pumpernickel with MIT License 4 votes vote down vote up
protected static void setIcon(AbstractButton button, Icon icon) {
	button.setIcon(icon);
	button.setRolloverIcon(new DarkenedIcon(icon, .5f));
	button.setPressedIcon(new DarkenedIcon(icon, .75f));
}