/**
* Returns the margin between the button's border and
* the label.
*
* @return an <code>Insets</code> object specifying the margin
* between the botton's border and the label
* @see #setMargin
*/
public Insets getMargin() {
return (margin == null) ? null : (Insets) margin.clone();
}
/**
* Returns the default icon.
* @return the default <code>Icon</code>
* @see #setIcon
*/
public Icon getIcon() {
return defaultIcon;
}
/**
* Sets the button's default icon. This icon is
* also used as the "pressed" and "disabled" icon if
* there is no explicitly set pressed icon.
*
* @param defaultIcon the icon used as the default image
* @see #getIcon
* @see #setPressedIcon
* @beaninfo
* bound: true
* attribute: visualUpdate true
* description: The button's default icon
*/
public void setIcon(Icon defaultIcon) {
Icon oldValue = this.defaultIcon;
this.defaultIcon = defaultIcon;
/* If the default icon has really changed and we had
* generated the disabled icon for this component,
* (i.e. setDisabledIcon() was never called) then
* clear the disabledIcon field.
*/
if (defaultIcon != oldValue && (disabledIcon instanceof UIResource)) {
disabledIcon = null;
}
firePropertyChange(ICON_CHANGED_PROPERTY, oldValue, defaultIcon);
if (accessibleContext != null) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
oldValue, defaultIcon);
}
if (defaultIcon != oldValue) {
if (defaultIcon == null || oldValue == null ||
defaultIcon.getIconWidth() != oldValue.getIconWidth() ||
defaultIcon.getIconHeight() != oldValue.getIconHeight()) {
revalidate();
}
repaint();
}
}
/**
* Returns the pressed icon for the button.
* @return the <code>pressedIcon</code> property
* @see #setPressedIcon
*/
public Icon getPressedIcon() {
return pressedIcon;
}
/**
* Sets the pressed icon for the button.
* @param pressedIcon the icon used as the "pressed" image
* @see #getPressedIcon
* @beaninfo
* bound: true
* attribute: visualUpdate true
* description: The pressed icon for the button.
*/
public void setPressedIcon(Icon pressedIcon) {
Icon oldValue = this.pressedIcon;
this.pressedIcon = pressedIcon;
firePropertyChange(PRESSED_ICON_CHANGED_PROPERTY, oldValue, pressedIcon);
if (accessibleContext != null) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
oldValue, pressedIcon);
}
if (pressedIcon != oldValue) {
if (getModel().isPressed()) {
repaint();
}
}
}
/**
* Returns the selected icon for the button.
* @return the <code>selectedIcon</code> property
=5= |