United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4939397 : SPEC BUG: java.awt.TextComponent 5 issues

Details
Type:
Bug
Submit Date:
2003-10-17
Status:
Closed
Updated Date:
2004-03-20
Project Name:
JDK
Resolved Date:
2004-02-17
Component:
docs
OS:
solaris_2.6,generic
Sub-Component:
guides
CPU:
sparc,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
5.0 (beta)

Related Reports
Relates:

Sub Tasks

Description

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

======================================================================

                                    

Comments
EVALUATION

The spec for the designated methods does not document some issues.
###@###.### 2003-10-17

Ran some tests, had Brent review proposed doc changes.  Approved by CCC.  Fixed for tiger.
###@###.### 2003-12-03
======================================================
The 5th bug issue is not resolved.

^C
For example:
  textComponent.setText("LONG TEXT");
  textComponent.setCaretPosition(6);
  textComponent.setText("");
  System.out.println(textComponent.getCaretPosition());

That was the 5th bug issue (as I noted) but in the consequent CCC
request it was mistakenly changed. From 

/ 5. expected behaviour for getCaretPosition if text has been changed 
     so the caret position is out of the new text bounds /

to

/ 5. Expected behavior for getCaretPosition if text hasn't been
                                                    ^^^^^^
     changed so the caret position is out of the new text bounds. /

--------------------------------

This will require a new CCC request and I can't resubmit under the same bug #, so I am closing this bug and creating a new bug.  I am putting this back to integrated (since the other issues are fixed and integrated).  See also bug #4995931.
###@###.### 2004-02-17
                                     
2004-02-17
PUBLIC COMMENTS

.
                                     
2004-08-28
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
generic

FIXED IN:
tiger-beta

INTEGRATED IN:
tiger-beta

VERIFIED IN:
tiger-b40


                                     
2004-08-28



Hardware and Software, Engineered to Work Together