javax.swing

Class AbstractButton.AccessibleAbstractButton

protected abstract class AbstractButton.AccessibleAbstractButton extends AccessibleJComponent implements AccessibleAction, AccessibleValue, AccessibleText

A Java Accessibility extension of the AbstractButton.
Constructor Summary
protected AccessibleAbstractButton()
Method Summary
booleandoAccessibleAction(int actionIndex)
Performs the acccessible action with the specified index on this object.
AccessibleActiongetAccessibleAction()
Returns the accessible action associated with this object.
intgetAccessibleActionCount()
Returns the number of accessible actions that are supported by this object.
StringgetAccessibleActionDescription(int actionIndex)
Returns a description for the action with the specified index or null if such action does not exist.
AccessibleIcon[]getAccessibleIcon()
Returns the accessible icons of this object.
StringgetAccessibleName()
Returns the accessible name for the button.
AccessibleRelationSetgetAccessibleRelationSet()
Returns the accessible relations of this AccessibleAbstractButton.
AccessibleStateSetgetAccessibleStateSet()
Returns the accessible state set of this object.
AccessibleTextgetAccessibleText()
Returns the accessible text for this AccessibleAbstractButton.
AccessibleValuegetAccessibleValue()
Returns the accessible value of this AccessibleAbstractButton, which is always this.
StringgetAfterIndex(int part, int index)
Returns the character, word or sentence after the specified index.
StringgetAtIndex(int part, int index)
Returns the character, word or sentence at the specified index.
StringgetBeforeIndex(int part, int index)
Returns the character, word or sentence before the specified index.
intgetCaretPosition()
This always returns -1 since there is no caret in a button.
AttributeSetgetCharacterAttribute(int i)
Returns the text attribute for the character at the specified character index.
RectanglegetCharacterBounds(int i)
Returns the bounds of the character at the specified index of the button's label.
intgetCharCount()
Returns the number of characters in the button's label.
NumbergetCurrentAccessibleValue()
Returns the current value of this object as a number.
intgetIndexAtPoint(Point p)
Returns the index of the label's character at the specified point, relative to the local bounds of the button.
NumbergetMaximumAccessibleValue()
Returns the maximum accessible value for the AccessibleAbstractButton, which is 1.
NumbergetMinimumAccessibleValue()
Returns the minimum accessible value for the AccessibleAbstractButton, which is 0.
StringgetSelectedText()
Returns the selected text.
intgetSelectionEnd()
This always returns -1 since button labels can't be selected.
intgetSelectionStart()
This always returns -1 since button labels can't be selected.
booleansetCurrentAccessibleValue(Number value)
Sets the current accessible value as object.

Constructor Detail

AccessibleAbstractButton

protected AccessibleAbstractButton()

Method Detail

doAccessibleAction

public boolean doAccessibleAction(int actionIndex)
Performs the acccessible action with the specified index on this object. Since buttons have only one action by default (which is to press the button), this method performs a 'press button' when the specified index is 0 and nothing otherwise.

Parameters: actionIndex a zero based index into the actions of this button

Returns: true if the specified action has been performed successfully, false otherwise

getAccessibleAction

public AccessibleAction getAccessibleAction()
Returns the accessible action associated with this object. For buttons, this will be this.

Returns: this

getAccessibleActionCount

public int getAccessibleActionCount()
Returns the number of accessible actions that are supported by this object. Buttons support one action by default ('press button'), so this method always returns 1.

Returns: 1, the number of supported accessible actions

getAccessibleActionDescription

public String getAccessibleActionDescription(int actionIndex)
Returns a description for the action with the specified index or null if such action does not exist.

Parameters: actionIndex the zero based index to the actions

Returns: a description for the action with the specified index or null if such action does not exist

getAccessibleIcon

public AccessibleIcon[] getAccessibleIcon()
Returns the accessible icons of this object. If the AbstractButton's icon is an Accessible, and it's AccessibleContext is an AccessibleIcon, then this AccessibleIcon is returned, otherwise null.

Returns: the accessible icons of this object, or null if there is no accessible icon

getAccessibleName

public String getAccessibleName()
Returns the accessible name for the button.

getAccessibleRelationSet

public AccessibleRelationSet getAccessibleRelationSet()
Returns the accessible relations of this AccessibleAbstractButton. If the AbstractButton is part of a ButtonGroup, then all the buttons in this button group are added as targets in a MEMBER_OF relation, otherwise an empty relation set is returned (from super).

Returns: the accessible relations of this AccessibleAbstractButton

getAccessibleStateSet

public AccessibleStateSet getAccessibleStateSet()
Returns the accessible state set of this object. In addition to the superclass's states, the AccessibleAbstractButton supports the following states: {@link AccessibleState#ARMED}, {@link AccessibleState#FOCUSED}, {@link AccessibleState#PRESSED} and {@link AccessibleState#CHECKED}.

Returns: the current state of this accessible object

getAccessibleText

public AccessibleText getAccessibleText()
Returns the accessible text for this AccessibleAbstractButton. This will be null if the button has a non-HTML label, otherwise this.

Returns: the accessible text for this AccessibleAbstractButton

getAccessibleValue

public AccessibleValue getAccessibleValue()
Returns the accessible value of this AccessibleAbstractButton, which is always this.

Returns: the accessible value of this AccessibleAbstractButton, which is always this

getAfterIndex

public String getAfterIndex(int part, int index)
Returns the character, word or sentence after the specified index. The part parameter determines what is returned, the character, word or sentence after the index.

Parameters: part one of {@link AccessibleText#CHARACTER}, {@link AccessibleText#WORD} or {@link AccessibleText#SENTENCE}, specifying what is returned index the index

Returns: the character, word or sentence after index

getAtIndex

public String getAtIndex(int part, int index)
Returns the character, word or sentence at the specified index. The part parameter determines what is returned, the character, word or sentence after the index.

Parameters: part one of {@link AccessibleText#CHARACTER}, {@link AccessibleText#WORD} or {@link AccessibleText#SENTENCE}, specifying what is returned index the index

Returns: the character, word or sentence after index

getBeforeIndex

public String getBeforeIndex(int part, int index)
Returns the character, word or sentence before the specified index. The part parameter determines what is returned, the character, word or sentence before the index.

Parameters: part one of {@link AccessibleText#CHARACTER}, {@link AccessibleText#WORD} or {@link AccessibleText#SENTENCE}, specifying what is returned index the index

Returns: the character, word or sentence before index

getCaretPosition

public int getCaretPosition()
This always returns -1 since there is no caret in a button.

Returns: -1 since there is no caret in a button

getCharacterAttribute

public AttributeSet getCharacterAttribute(int i)
Returns the text attribute for the character at the specified character index.

Parameters: i the character index

Returns: the character attributes for the specified character or null if the character has no attributes

getCharacterBounds

public Rectangle getCharacterBounds(int i)
Returns the bounds of the character at the specified index of the button's label. This will only work for HTML labels.

Parameters: i the index of the character of the label

Returns: the bounds of the character at the specified index of the button's label

getCharCount

public int getCharCount()
Returns the number of characters in the button's label.

Returns: the bounds of the character at the specified index of the button's label

getCurrentAccessibleValue

public Number getCurrentAccessibleValue()
Returns the current value of this object as a number. This implementation returns an Integer(1) if the button is selected, Integer(0) if the button is not selected.

Returns: the current value of this object as a number

getIndexAtPoint

public int getIndexAtPoint(Point p)
Returns the index of the label's character at the specified point, relative to the local bounds of the button. This only works for HTML labels.

Parameters: p the point, relative to the buttons local bounds

Returns: the index of the label's character at the specified point

getMaximumAccessibleValue

public Number getMaximumAccessibleValue()
Returns the maximum accessible value for the AccessibleAbstractButton, which is 1.

Returns: the maximum accessible value for the AccessibleAbstractButton, which is 1

getMinimumAccessibleValue

public Number getMinimumAccessibleValue()
Returns the minimum accessible value for the AccessibleAbstractButton, which is 0.

Returns: the minimimum accessible value for the AccessibleAbstractButton, which is 0

getSelectedText

public String getSelectedText()
Returns the selected text. This always returns null since button labels can't be selected.

Returns: null, button labels can't be selected

getSelectionEnd

public int getSelectionEnd()
This always returns -1 since button labels can't be selected.

Returns: -1, button labels can't be selected

getSelectionStart

public int getSelectionStart()
This always returns -1 since button labels can't be selected.

Returns: -1, button labels can't be selected

setCurrentAccessibleValue

public boolean setCurrentAccessibleValue(Number value)
Sets the current accessible value as object. If the specified number is 0 the button will be deselected, otherwise the button will be selected.

Parameters: value 0 for deselected button, other for selected button

Returns: true if the value has been set, false otherwise