United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4198834 ListDataEvent.getIndex0() should be <= getIndex1()
JDK-4198834 : ListDataEvent.getIndex0() should be <= getIndex1()

Details
Type:
Bug
Submit Date:
1998-12-20
Status:
Resolved
Updated Date:
2003-06-06
Project Name:
JDK
Resolved Date:
2003-06-06
Component:
client-libs
OS:
generic
Sub-Component:
javax.swing
CPU:
generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.0
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

Description

Name: krT82822			Date: 12/20/98


AbstractListModel.fireContentsChanged() says
that index0 need not be <= index1.
Yet, ListDataEvent says that index0 is "lower"
index value.

I recommend that AbstractListModel.fireContentsChanged()
docs be changed to say index0 must be <= index1.
(which is always the case now anyways).

If that's no good, then add the code to swap index0 and
index1 if necessary.

Under no circumstances should ListDataEvent.getIndex0() be
changed to be possibly bigger than getIndex1().  The reason
is that you have to include some yucky code to handle the 
possibility.  The second reason is that most people will
not write the appropriate code anyways (since it will
work fine presently).  And so if in the future you ever
want to make index0 bigger than index1, you'll break everyone's
code. In other words, you won't be able to do it anyways.
So you might as well be clear here.

Besides, the restriction that index0 <= index1 is not onerous
but handling the case is onerous.

cheers,
pat
(Review ID: 48508)
======================================================================

                                    

Comments
EVALUATION

I agree, AbsractListModel should swap the indexs as necessary so that ListDataEvent is created correctly.
scott.violet@eng 1999-09-22

Actually, ListDataEvent should probably do this, that way everyone will pick it up.
###@###.### 2001-10-22
                                     
1999-09-22
WORK AROUND



Name: krT82822			Date: 12/20/98


int i = evt.getIndex0();
int j = evt.getIndex1();
if (i > j) {
  int t = i;
  i = j;
  j = t;
}
for (i=0; i<=j; i++) {
  evt.getElementAt(i);
}
======================================================================
                                     
2004-08-24
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b09


                                     
2004-08-24



Hardware and Software, Engineered to Work Together