Name: sdR10048 Date: 10/17/2003
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b23"
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
public void setCaretPosition(int position)
Sets the position of the text insertion caret for this text component.
The caret position is constrained to be at or before the current
selection end. If the caller supplies a value for position that is
greater than the end of the component's text, the caret position
is set to the end of the component's text. This happens silently
and without failure. The caret position also cannot be set to less
than zero, the beginning of the component's text. If the caller
supplies a value for position that is less than zero, an I
llegalArgumentException is thrown.
Parameters:
position - the position of the text insertion caret
Throws:
IllegalArgumentException - if the value supplied for position is less than zero
===
public int getCaretPosition()
Gets the position of the text insertion caret for this text component.
Returns:
the position of the text insertion caret
===
public String getText()
Returns the text that is presented by this text component.
...
---------- end-of-excerpt ---------------
Problem description
===================
The spec for the designated methods does not document some issues:
1. the default component's text value if it has not been set before
2. expected behaviour for setCaretPosition if text has not been set before
3. expected behaviour for getCaretPosition if text has not been set before
4. expected behaviour for getCaretPosition if caret position has not been set before
5. expected behaviour for getCaretPosition if text has been changed
so the caret position is out of the new text bounds
======================================================================
- relates to
-
JDK-4995931 java.awt.TextComponent caret position does not follow spec
- Resolved