/**
* The button model's <code>ActionListener</code>.
*/
protected ActionListener actionListener = null;
/**
* The button model's <code>ItemListener</code>.
*/
protected ItemListener itemListener = null;
/**
* Only one <code>ChangeEvent</code> is needed per button
* instance since the
* event's only state is the source property. The source of events
* generated is always "this".
*/
protected transient ChangeEvent changeEvent;
private boolean hideActionText = false;
/**
* Sets the <code>hideActionText</code> property, which determines
* whether the button displays text from the <code>Action</code>.
* This is useful only if an <code>Action</code> has been
* installed on the button.
*
* @param hideActionText <code>true</code> if the button's
* <code>text</code> property should not reflect
* that of the <code>Action</code>; the default is
* <code>false</code>
* @see <a href="Action.html#buttonActions">Swing Components Supporting
* <code>Action</code></a>
* @since 1.6
* @beaninfo
* bound: true
* expert: true
* description: Whether the text of the button should come from
* the <code>Action</code>.
*/
public void setHideActionText(boolean hideActionText) {
if (hideActionText != this.hideActionText) {
this.hideActionText = hideActionText;
if (getAction() != null) {
setTextFromAction(getAction(), false);
}
firePropertyChange("hideActionText", !hideActionText,
hideActionText);
}
}
/**
* Returns the value of the <code>hideActionText</code> property, which
* determines whether the button displays text from the
* <code>Action</code>. This is useful only if an <code>Action</code>
* has been installed on the button.
*
* @return <code>true</code> if the button's <code>text</code>
* property should not reflect that of the
* <code>Action</code>; the default is <code>false</code>
* @since 1.6
*/
public boolean getHideActionText() {
return hideActionText;
}
/**
* Returns the button's text.
* @return the buttons text
* @see #setText
*/
public String getText() {
return text;
}
/**
* Sets the button's text.
* @param text the string used to set the text
* @see #getText
* @beaninfo
* bound: true
* preferred: true
* attribute: visualUpdate true
* description: The button's text.
*/
public void setText(String text) {
String oldValue = this.text;
this.text = text;
firePropertyChange(TEXT_CHANGED_PROPERTY, oldValue, text);
updateDisplayedMnemonicIndex(text, getMnemonic());
if (accessibleContext != null) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
oldValue, text);
}
if (text == null || oldValue == null || !text.equals(oldValue)) {
revalidate();
repaint();
}
}
=3= |