This method sets the start and end positions of the selected text, enforcing the restriction that the start position must be greater than or equal to zero. The end position must be greater than or equal to the start position, and less than or equal to the length of the text component's text. The character positions are indexed starting with zero. The length of the selection is endPosition
- startPosition
, so the character at endPosition
is not selected. If the start and end positions of the selected text are equal, all text is deselected.
If the caller supplies values that are inconsistent or out of bounds, the method enforces these constraints silently, and without failure. Specifically, if the start position or end position is greater than the length of the text, it is reset to equal the text length. If the start position is less than zero, it is reset to zero, and if the end position is less than the start position, it is reset to the start position.
@param selectionStart the zero-based index of the first character (char
value) to be selected
@param selectionEnd the zero-based end position of the text to be selected; the character (char
value) at selectionEnd
is not selected
@see java.awt.TextComponent#setSelectionStart
@see java.awt.TextComponent#setSelectionEnd
@see java.awt.TextComponent#selectAll
|
|
|
|