javax.swing

Class JLabel.AccessibleJLabel

protected class JLabel.AccessibleJLabel extends JComponent.AccessibleJComponent implements AccessibleText, AccessibleExtendedComponent

Provides the accessibility features for the JLabel component.
Method Summary
StringgetAccessibleName()
Returns the accessible name.
AccessibleRolegetAccessibleRole()
Returns the accessible role for the JLabel component.
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()
Returns the caret position.
AttributeSetgetCharacterAttribute(int index)
Returns an {@link AttributeSet} that reflects the text attributes of the specified character.
RectanglegetCharacterBounds(int index)
Returns the bounding box of the character at the specified index.
intgetCharCount()
Returns the number of characters that are displayed by the JLabel.
intgetIndexAtPoint(Point point)
Returns the index of the character that is located at the specified point.
StringgetSelectedText()
Returns the selected text.
intgetSelectionEnd()
Returns the end index of the selected text.
intgetSelectionStart()
Returns the start index of the selected text.

Method Detail

getAccessibleName

public String getAccessibleName()
Returns the accessible name.

Returns: The accessible name.

getAccessibleRole

public AccessibleRole getAccessibleRole()
Returns the accessible role for the JLabel component.

Returns: {@link AccessibleRole#LABEL}.

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()
Returns the caret position. This method returns -1 because JLabel don't have a caret.

Returns: the caret position

getCharacterAttribute

public AttributeSet getCharacterAttribute(int index)
Returns an {@link AttributeSet} that reflects the text attributes of the specified character. We return an empty AttributeSet here, because JLabels don't support text attributes (at least not yet).

Parameters: index the index of the character

Returns: an {@link AttributeSet} that reflects the text attributes of the specified character

getCharacterBounds

public Rectangle getCharacterBounds(int index)
Returns the bounding box of the character at the specified index.

Parameters: index the index of the character that we return the bounds for

Returns: the bounding box of the character at the specified index

getCharCount

public int getCharCount()
Returns the number of characters that are displayed by the JLabel.

Returns: the number of characters that are displayed by the JLabel

getIndexAtPoint

public int getIndexAtPoint(Point point)
Returns the index of the character that is located at the specified point.

Parameters: point the location that we lookup the character for

Returns: the index of the character that is located at the specified point

getSelectedText

public String getSelectedText()
Returns the selected text. This is null since JLabels are not selectable.

Returns: null because JLabels cannot have selected text

getSelectionEnd

public int getSelectionEnd()
Returns the end index of the selected text.

Returns: the end index of the selected text

getSelectionStart

public int getSelectionStart()
Returns the start index of the selected text.

Returns: the start index of the selected text