firePropertyChange(HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY,
oldValue,
horizontalTextPosition);
revalidate();
repaint();
}
/**
* Returns the amount of space between the text and the icon
* displayed in this button.
*
* @return an int equal to the number of pixels between the text
* and the icon.
* @since 1.4
* @see #setIconTextGap
*/
public int getIconTextGap() {
return iconTextGap;
}
/**
* If both the icon and text properties are set, this property
* defines the space between them.
* <p>
* The default value of this property is 4 pixels.
* <p>
* This is a JavaBeans bound property.
*
* @since 1.4
* @see #getIconTextGap
* @beaninfo
* bound: true
* attribute: visualUpdate true
* description: If both the icon and text properties are set, this
* property defines the space between them.
*/
public void setIconTextGap(int iconTextGap) {
int oldValue = this.iconTextGap;
this.iconTextGap = iconTextGap;
iconTextGapSet = true;
firePropertyChange("iconTextGap", oldValue, iconTextGap);
if (iconTextGap != oldValue) {
revalidate();
repaint();
}
}
/**
* Verify that the {@code key} argument is a legal value for the
* {@code horizontalAlignment} and {@code horizontalTextPosition}
* properties. Valid values are:
* <ul>
* <li>{@code SwingConstants.RIGHT}
* <li>{@code SwingConstants.LEFT}
* <li>{@code SwingConstants.CENTER}
* <li>{@code SwingConstants.LEADING}
* <li>{@code SwingConstants.TRAILING}
* </ul>
*
* @param key the property value to check
* @param exception the message to use in the
* {@code IllegalArgumentException} that is thrown for an invalid
* value
* @exception IllegalArgumentException if key is not one of the legal
* values listed above
* @see #setHorizontalTextPosition
* @see #setHorizontalAlignment
*/
protected int checkHorizontalKey(int key, String exception) {
if ((key == LEFT) ||
(key == CENTER) ||
(key == RIGHT) ||
(key == LEADING) ||
(key == TRAILING)) {
return key;
} else {
throw new IllegalArgumentException(exception);
}
}
/**
* Verify that the {@code key} argument is a legal value for the
* vertical properties. Valid values are:
* <ul>
* <li>{@code SwingConstants.CENTER}
* <li>{@code SwingConstants.TOP}
* <li>{@code SwingConstants.BOTTOM}
* </ul>
*
* @param key the property value to check
* @param exception the message to use in the
* {@code IllegalArgumentException} that is thrown for an invalid
* value
* @exception IllegalArgumentException if key is not one of the legal
* values listed above
*/
protected int checkVerticalKey(int key, String exception) {
if ((key == TOP) || (key == CENTER) || (key == BOTTOM)) {
return key;
} else {
=10= |