Determines the bounding box of the character at the given
index into the string. The bounds are returned in local
coordinates. If the index is invalid a null rectangle
is returned.
The screen coordinates returned are "unscrolled coordinates"
if the JTextComponent is contained in a JScrollPane in which
case the resulting rectangle should be composed with the parent
coordinates. A good algorithm to use is:
Accessible a:
AccessibleText at = a.getAccessibleText();
AccessibleComponent ac = a.getAccessibleComponent();
Rectangle r = at.getCharacterBounds();
Point p = ac.getLocation();
r.x += p.x;
r.y += p.y;
Note: the JTextComponent must have a valid size (e.g. have
been added to a parent container whose ancestor container
is a valid top-level window) for this method to be able
to return a meaningful (non-null) value.
Returns:
the screen coordinates of the character's bounding box
Parameters:
-
i - the index into the String >= 0