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 * @see #setSelectedIcon */ public Icon getSelectedIcon() { return selectedIcon; } /** * Sets the selected icon for the button. * @param selectedIcon the icon used as the "selected" image * @see #getSelectedIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The selected icon for the button. */ public void setSelectedIcon(Icon selectedIcon) { Icon oldValue = this.selectedIcon; this.selectedIcon = selectedIcon; /* If the default selected icon has really changed and we had * generated the disabled selected icon for this component, * (i.e. setDisabledSelectedIcon() was never called) then * clear the disabledSelectedIcon field. */ if (selectedIcon != oldValue && disabledSelectedIcon instanceof UIResource) { disabledSelectedIcon = null; } firePropertyChange(SELECTED_ICON_CHANGED_PROPERTY, oldValue, selectedIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, selectedIcon); } if (selectedIcon != oldValue) { if (isSelected()) { repaint(); } } } /** * Returns the rollover icon for the button. * @return the <code>rolloverIcon</code> property * @see #setRolloverIcon */ public Icon getRolloverIcon() { return rolloverIcon; } /** * Sets the rollover icon for the button. * @param rolloverIcon the icon used as the "rollover" image * @see #getRolloverIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The rollover icon for the button. */ public void setRolloverIcon(Icon rolloverIcon) { Icon oldValue = this.rolloverIcon; this.rolloverIcon = rolloverIcon; firePropertyChange(ROLLOVER_ICON_CHANGED_PROPERTY, oldValue, rolloverIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, rolloverIcon); } setRolloverEnabled(true); if (rolloverIcon != oldValue) { // No way to determine whether we are currently in // a rollover state, so repaint regardless repaint(); } } /** * Returns the rollover selection icon for the button. * @return the <code>rolloverSelectedIcon</code> property * @see #setRolloverSelectedIcon */ public Icon getRolloverSelectedIcon() { return rolloverSelectedIcon; } /** * Sets the rollover selected icon for the button. * @param rolloverSelectedIcon the icon used as the * "selected rollover" image * @see #getRolloverSelectedIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The rollover selected icon for the button. */ public void setRolloverSelectedIcon(Icon rolloverSelectedIcon) { Icon oldValue = this.rolloverSelectedIcon; this.rolloverSelectedIcon = rolloverSelectedIcon; firePropertyChange(ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, oldValue, rolloverSelectedIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, rolloverSelectedIcon); } setRolloverEnabled(true); if (rolloverSelectedIcon != oldValue) { // No way to determine whether we are currently in // a rollover state, so repaint regardless if (isSelected()) { repaint(); } } } /** * Returns the icon used by the button when it's disabled. * If no disabled icon has been set this will forward the call to * the look and feel to construct an appropriate disabled Icon. * <p> * Some look and feels might not render the disabled Icon, in which * case they will ignore this. * * @return the <code>disabledIcon</code> property * @see #getPressedIcon * @see #setDisabledIcon * @see javax.swing.LookAndFeel#getDisabledIcon */ @Transient public Icon getDisabledIcon() { if (disabledIcon == null) { disabledIcon = UIManager.getLookAndFeel().getDisabledIcon(this, getIcon()); if (disabledIcon != null) { firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, null, disabledIcon); } } return disabledIcon; } /** * Sets the disabled icon for the button. * @param disabledIcon the icon used as the disabled image * @see #getDisabledIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The disabled icon for the button. */ public void setDisabledIcon(Icon disabledIcon) { Icon oldValue = this.disabledIcon; this.disabledIcon = disabledIcon; firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, oldValue, disabledIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, disabledIcon); } if (disabledIcon != oldValue) { if (!isEnabled()) { repaint(); } } } /** * Returns the icon used by the button when it's disabled and selected. * If no disabled selection icon has been set, this will forward * the call to the LookAndFeel to construct an appropriate disabled * Icon from the selection icon if it has been set and to * <code>getDisabledIcon()</code> otherwise. * <p> * Some look and feels might not render the disabled selected Icon, in * which case they will ignore this. * * @return the <code>disabledSelectedIcon</code> property * @see #getDisabledIcon * @see #setDisabledSelectedIcon * @see javax.swing.LookAndFeel#getDisabledSelectedIcon */ public Icon getDisabledSelectedIcon() { if (disabledSelectedIcon == null) { if (selectedIcon != null) { disabledSelectedIcon = UIManager.getLookAndFeel(). getDisabledSelectedIcon(this, getSelectedIcon()); } else { return getDisabledIcon(); } } return disabledSelectedIcon; } /** * Sets the disabled selection icon for the button. * @param disabledSelectedIcon the icon used as the disabled * selection image * @see #getDisabledSelectedIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The disabled selection icon for the button. */ public void setDisabledSelectedIcon(Icon disabledSelectedIcon) { Icon oldValue = this.disabledSelectedIcon; this.disabledSelectedIcon = disabledSelectedIcon; firePropertyChange(DISABLED_SELECTED_ICON_CHANGED_PROPERTY, oldValue, disabledSelectedIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, disabledSelectedIcon); } if (disabledSelectedIcon != oldValue) { if (disabledSelectedIcon == null || oldValue == null || disabledSelectedIcon.getIconWidth() != oldValue.getIconWidth() || disabledSelectedIcon.getIconHeight() != oldValue.getIconHeight()) { revalidate(); } if (!isEnabled() && isSelected()) { repaint(); } } } /** * Returns the vertical alignment of the text and icon. * * @return the <code>verticalAlignment</code> property, one of the * following values: * <ul> * <li>{@code SwingConstants.CENTER} (the default) * <li>{@code SwingConstants.TOP} * <li>{@code SwingConstants.BOTTOM} * </ul> */ public int getVerticalAlignment() { return verticalAlignment; } /** * Sets the vertical alignment of the icon and text. * @param alignment one of the following values: * <ul> * <li>{@code SwingConstants.CENTER} (the default) * <li>{@code SwingConstants.TOP} * <li>{@code SwingConstants.BOTTOM} * </ul> * @throws IllegalArgumentException if the alignment is not one of the legal * values listed above * @beaninfo * bound: true * enum: TOP SwingConstants.TOP * CENTER SwingConstants.CENTER * BOTTOM SwingConstants.BOTTOM * attribute: visualUpdate true * description: The vertical alignment of the icon and text. */ public void setVerticalAlignment(int alignment) { if (alignment == verticalAlignment) return; int oldValue = verticalAlignment; verticalAlignment = checkVerticalKey(alignment, "verticalAlignment"); firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, oldValue, verticalAlignment); repaint(); } /** * Returns the horizontal alignment of the icon and text. * {@code AbstractButton}'s default is {@code SwingConstants.CENTER}, * but subclasses such as {@code JCheckBox} may use a different default. * * @return the <code>horizontalAlignment</code> property, * one of the following values: * <ul> * <li>{@code SwingConstants.RIGHT} * <li>{@code SwingConstants.LEFT} * <li>{@code SwingConstants.CENTER} * <li>{@code SwingConstants.LEADING} * <li>{@code SwingConstants.TRAILING} * </ul> */ public int getHorizontalAlignment() { return horizontalAlignment; } /** * Sets the horizontal alignment of the icon and text. * {@code AbstractButton}'s default is {@code SwingConstants.CENTER}, * but subclasses such as {@code JCheckBox} may use a different default. * * @param alignment the alignment value, one of the following values: * <ul> * <li>{@code SwingConstants.RIGHT} * <li>{@code SwingConstants.LEFT} * <li>{@code SwingConstants.CENTER} * <li>{@code SwingConstants.LEADING} * <li>{@code SwingConstants.TRAILING} * </ul> * @throws IllegalArgumentException if the alignment is not one of the * valid values * @beaninfo * bound: true * enum: LEFT SwingConstants.LEFT * CENTER SwingConstants.CENTER * RIGHT SwingConstants.RIGHT * LEADING SwingConstants.LEADING * TRAILING SwingConstants.TRAILING * attribute: visualUpdate true * description: The horizontal alignment of the icon and text. */ public void setHorizontalAlignment(int alignment) { if (alignment == horizontalAlignment) return; int oldValue = horizontalAlignment; horizontalAlignment = checkHorizontalKey(alignment, "horizontalAlignment"); firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, oldValue, horizontalAlignment); repaint(); } /** * Returns the vertical position of the text relative to the icon. * @return the <code>verticalTextPosition</code> property, * one of the following values: * <ul> * <li>{@code SwingConstants.CENTER} (the default) * <li>{@code SwingConstants.TOP} * <li>{@code SwingConstants.BOTTOM} * </ul> */ public int getVerticalTextPosition() { return verticalTextPosition; } /** * Sets the vertical position of the text relative to the icon. * @param textPosition one of the following values: * <ul> * <li>{@code SwingConstants.CENTER} (the default) * <li>{@code SwingConstants.TOP} * <li>{@code SwingConstants.BOTTOM} * </ul> * @beaninfo * bound: true * enum: TOP SwingConstants.TOP * CENTER SwingConstants.CENTER * BOTTOM SwingConstants.BOTTOM * attribute: visualUpdate true * description: The vertical position of the text relative to the icon. */ public void setVerticalTextPosition(int textPosition) { if (textPosition == verticalTextPosition) return; int oldValue = verticalTextPosition; verticalTextPosition = checkVerticalKey(textPosition, "verticalTextPosition"); firePropertyChange(VERTICAL_TEXT_POSITION_CHANGED_PROPERTY, oldValue, verticalTextPosition); revalidate(); repaint(); } /** * Returns the horizontal position of the text relative to the icon. * @return the <code>horizontalTextPosition</code> property, * one of the following values: * <ul> * <li>{@code SwingConstants.RIGHT} * <li>{@code SwingConstants.LEFT} * <li>{@code SwingConstants.CENTER} * <li>{@code SwingConstants.LEADING} * <li>{@code SwingConstants.TRAILING} (the default) * </ul> */ public int getHorizontalTextPosition() { return horizontalTextPosition; } /** * Sets the horizontal position of the text relative to the icon. * @param textPosition one of the following values: * <ul> * <li>{@code SwingConstants.RIGHT} * <li>{@code SwingConstants.LEFT} * <li>{@code SwingConstants.CENTER} * <li>{@code SwingConstants.LEADING} * <li>{@code SwingConstants.TRAILING} (the default) * </ul> * @exception IllegalArgumentException if <code>textPosition</code> * is not one of the legal values listed above * @beaninfo * bound: true * enum: LEFT SwingConstants.LEFT * CENTER SwingConstants.CENTER * RIGHT SwingConstants.RIGHT * LEADING SwingConstants.LEADING * TRAILING SwingConstants.TRAILING * attribute: visualUpdate true * description: The horizontal position of the text relative to the icon. */ public void setHorizontalTextPosition(int textPosition) { if (textPosition == horizontalTextPosition) return; int oldValue = horizontalTextPosition; horizontalTextPosition = checkHorizontalKey(textPosition, "horizontalTextPosition"); 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); } } Lines 501–1000 of 3101. Previous lines Load more
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 * @see #setSelectedIcon */ public Icon getSelectedIcon() { return selectedIcon; } /** * Sets the selected icon for the button. * @param selectedIcon the icon used as the "selected" image * @see #getSelectedIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The selected icon for the button. */ public void setSelectedIcon(Icon selectedIcon) { Icon oldValue = this.selectedIcon; this.selectedIcon = selectedIcon; /* If the default selected icon has really changed and we had * generated the disabled selected icon for this component, * (i.e. setDisabledSelectedIcon() was never called) then * clear the disabledSelectedIcon field. */ if (selectedIcon != oldValue && disabledSelectedIcon instanceof UIResource) { disabledSelectedIcon = null; } firePropertyChange(SELECTED_ICON_CHANGED_PROPERTY, oldValue, selectedIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, selectedIcon); } if (selectedIcon != oldValue) { if (isSelected()) { repaint(); } } } /** * Returns the rollover icon for the button. * @return the <code>rolloverIcon</code> property * @see #setRolloverIcon */ public Icon getRolloverIcon() { return rolloverIcon; } /** * Sets the rollover icon for the button. * @param rolloverIcon the icon used as the "rollover" image * @see #getRolloverIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The rollover icon for the button. */ public void setRolloverIcon(Icon rolloverIcon) { Icon oldValue = this.rolloverIcon; this.rolloverIcon = rolloverIcon; firePropertyChange(ROLLOVER_ICON_CHANGED_PROPERTY, oldValue, rolloverIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, rolloverIcon); } setRolloverEnabled(true); if (rolloverIcon != oldValue) { // No way to determine whether we are currently in // a rollover state, so repaint regardless repaint(); } } /** * Returns the rollover selection icon for the button. * @return the <code>rolloverSelectedIcon</code> property * @see #setRolloverSelectedIcon */ public Icon getRolloverSelectedIcon() { return rolloverSelectedIcon; } /** * Sets the rollover selected icon for the button. * @param rolloverSelectedIcon the icon used as the * "selected rollover" image * @see #getRolloverSelectedIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The rollover selected icon for the button. */ public void setRolloverSelectedIcon(Icon rolloverSelectedIcon) { Icon oldValue = this.rolloverSelectedIcon; this.rolloverSelectedIcon = rolloverSelectedIcon; firePropertyChange(ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, oldValue, rolloverSelectedIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, rolloverSelectedIcon); } setRolloverEnabled(true); if (rolloverSelectedIcon != oldValue) { // No way to determine whether we are currently in // a rollover state, so repaint regardless if (isSelected()) { repaint(); } } } /** * Returns the icon used by the button when it's disabled. * If no disabled icon has been set this will forward the call to * the look and feel to construct an appropriate disabled Icon. * <p> * Some look and feels might not render the disabled Icon, in which * case they will ignore this. * * @return the <code>disabledIcon</code> property * @see #getPressedIcon * @see #setDisabledIcon * @see javax.swing.LookAndFeel#getDisabledIcon */ @Transient public Icon getDisabledIcon() { if (disabledIcon == null) { disabledIcon = UIManager.getLookAndFeel().getDisabledIcon(this, getIcon()); if (disabledIcon != null) { firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, null, disabledIcon); } } return disabledIcon; } /** * Sets the disabled icon for the button. * @param disabledIcon the icon used as the disabled image * @see #getDisabledIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The disabled icon for the button. */ public void setDisabledIcon(Icon disabledIcon) { Icon oldValue = this.disabledIcon; this.disabledIcon = disabledIcon; firePropertyChange(DISABLED_ICON_CHANGED_PROPERTY, oldValue, disabledIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, disabledIcon); } if (disabledIcon != oldValue) { if (!isEnabled()) { repaint(); } } } /** * Returns the icon used by the button when it's disabled and selected. * If no disabled selection icon has been set, this will forward * the call to the LookAndFeel to construct an appropriate disabled * Icon from the selection icon if it has been set and to * <code>getDisabledIcon()</code> otherwise. * <p> * Some look and feels might not render the disabled selected Icon, in * which case they will ignore this. * * @return the <code>disabledSelectedIcon</code> property * @see #getDisabledIcon * @see #setDisabledSelectedIcon * @see javax.swing.LookAndFeel#getDisabledSelectedIcon */ public Icon getDisabledSelectedIcon() { if (disabledSelectedIcon == null) { if (selectedIcon != null) { disabledSelectedIcon = UIManager.getLookAndFeel(). getDisabledSelectedIcon(this, getSelectedIcon()); } else { return getDisabledIcon(); } } return disabledSelectedIcon; } /** * Sets the disabled selection icon for the button. * @param disabledSelectedIcon the icon used as the disabled * selection image * @see #getDisabledSelectedIcon * @beaninfo * bound: true * attribute: visualUpdate true * description: The disabled selection icon for the button. */ public void setDisabledSelectedIcon(Icon disabledSelectedIcon) { Icon oldValue = this.disabledSelectedIcon; this.disabledSelectedIcon = disabledSelectedIcon; firePropertyChange(DISABLED_SELECTED_ICON_CHANGED_PROPERTY, oldValue, disabledSelectedIcon); if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, oldValue, disabledSelectedIcon); } if (disabledSelectedIcon != oldValue) { if (disabledSelectedIcon == null || oldValue == null || disabledSelectedIcon.getIconWidth() != oldValue.getIconWidth() || disabledSelectedIcon.getIconHeight() != oldValue.getIconHeight()) { revalidate(); } if (!isEnabled() && isSelected()) { repaint(); } } } /** * Returns the vertical alignment of the text and icon. * * @return the <code>verticalAlignment</code> property, one of the * following values: * <ul> * <li>{@code SwingConstants.CENTER} (the default) * <li>{@code SwingConstants.TOP} * <li>{@code SwingConstants.BOTTOM} * </ul> */ public int getVerticalAlignment() { return verticalAlignment; } /** * Sets the vertical alignment of the icon and text. * @param alignment one of the following values: * <ul> * <li>{@code SwingConstants.CENTER} (the default) * <li>{@code SwingConstants.TOP} * <li>{@code SwingConstants.BOTTOM} * </ul> * @throws IllegalArgumentException if the alignment is not one of the legal * values listed above * @beaninfo * bound: true * enum: TOP SwingConstants.TOP * CENTER SwingConstants.CENTER * BOTTOM SwingConstants.BOTTOM * attribute: visualUpdate true * description: The vertical alignment of the icon and text. */ public void setVerticalAlignment(int alignment) { if (alignment == verticalAlignment) return; int oldValue = verticalAlignment; verticalAlignment = checkVerticalKey(alignment, "verticalAlignment"); firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, oldValue, verticalAlignment); repaint(); } /** * Returns the horizontal alignment of the icon and text. * {@code AbstractButton}'s default is {@code SwingConstants.CENTER}, * but subclasses such as {@code JCheckBox} may use a different default. * * @return the <code>horizontalAlignment</code> property, * one of the following values: * <ul> * <li>{@code SwingConstants.RIGHT} * <li>{@code SwingConstants.LEFT} * <li>{@code SwingConstants.CENTER} * <li>{@code SwingConstants.LEADING} * <li>{@code SwingConstants.TRAILING} * </ul> */ public int getHorizontalAlignment() { return horizontalAlignment; } /** * Sets the horizontal alignment of the icon and text. * {@code AbstractButton}'s default is {@code SwingConstants.CENTER}, * but subclasses such as {@code JCheckBox} may use a different default. * * @param alignment the alignment value, one of the following values: * <ul> * <li>{@code SwingConstants.RIGHT} * <li>{@code SwingConstants.LEFT} * <li>{@code SwingConstants.CENTER} * <li>{@code SwingConstants.LEADING} * <li>{@code SwingConstants.TRAILING} * </ul> * @throws IllegalArgumentException if the alignment is not one of the * valid values * @beaninfo * bound: true * enum: LEFT SwingConstants.LEFT * CENTER SwingConstants.CENTER * RIGHT SwingConstants.RIGHT * LEADING SwingConstants.LEADING * TRAILING SwingConstants.TRAILING * attribute: visualUpdate true * description: The horizontal alignment of the icon and text. */ public void setHorizontalAlignment(int alignment) { if (alignment == horizontalAlignment) return; int oldValue = horizontalAlignment; horizontalAlignment = checkHorizontalKey(alignment, "horizontalAlignment"); firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, oldValue, horizontalAlignment); repaint(); } /** * Returns the vertical position of the text relative to the icon. * @return the <code>verticalTextPosition</code> property, * one of the following values: * <ul> * <li>{@code SwingConstants.CENTER} (the default) * <li>{@code SwingConstants.TOP} * <li>{@code SwingConstants.BOTTOM} * </ul> */ public int getVerticalTextPosition() { return verticalTextPosition; } /** * Sets the vertical position of the text relative to the icon. * @param textPosition one of the following values: * <ul> * <li>{@code SwingConstants.CENTER} (the default) * <li>{@code SwingConstants.TOP} * <li>{@code SwingConstants.BOTTOM} * </ul> * @beaninfo * bound: true * enum: TOP SwingConstants.TOP * CENTER SwingConstants.CENTER * BOTTOM SwingConstants.BOTTOM * attribute: visualUpdate true * description: The vertical position of the text relative to the icon. */ public void setVerticalTextPosition(int textPosition) { if (textPosition == verticalTextPosition) return; int oldValue = verticalTextPosition; verticalTextPosition = checkVerticalKey(textPosition, "verticalTextPosition"); firePropertyChange(VERTICAL_TEXT_POSITION_CHANGED_PROPERTY, oldValue, verticalTextPosition); revalidate(); repaint(); } /** * Returns the horizontal position of the text relative to the icon. * @return the <code>horizontalTextPosition</code> property, * one of the following values: * <ul> * <li>{@code SwingConstants.RIGHT} * <li>{@code SwingConstants.LEFT} * <li>{@code SwingConstants.CENTER} * <li>{@code SwingConstants.LEADING} * <li>{@code SwingConstants.TRAILING} (the default) * </ul> */ public int getHorizontalTextPosition() { return horizontalTextPosition; } /** * Sets the horizontal position of the text relative to the icon. * @param textPosition one of the following values: * <ul> * <li>{@code SwingConstants.RIGHT} * <li>{@code SwingConstants.LEFT} * <li>{@code SwingConstants.CENTER} * <li>{@code SwingConstants.LEADING} * <li>{@code SwingConstants.TRAILING} (the default) * </ul> * @exception IllegalArgumentException if <code>textPosition</code> * is not one of the legal values listed above * @beaninfo * bound: true * enum: LEFT SwingConstants.LEFT * CENTER SwingConstants.CENTER * RIGHT SwingConstants.RIGHT * LEADING SwingConstants.LEADING * TRAILING SwingConstants.TRAILING * attribute: visualUpdate true * description: The horizontal position of the text relative to the icon. */ public void setHorizontalTextPosition(int textPosition) { if (textPosition == horizontalTextPosition) return; int oldValue = horizontalTextPosition; horizontalTextPosition = checkHorizontalKey(textPosition, "horizontalTextPosition"); 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); } }