Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4198834
Votes 0
Synopsis ListDataEvent.getIndex0() should be <= getIndex1()
Category java:classes_swing
Reported Against 1.2fcs
Release Fixed 1.5(tiger)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs 4885474 , 4884948
Submit Date 20-DEC-1998
Description




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  xxxxx  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)
======================================================================
Work Around




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);
}
======================================================================
Evaluation
I agree, AbsractListModel should swap the indexs as necessary so that ListDataEvent is created correctly.
 xxxxx@xxxxx  1999-09-22

Actually, ListDataEvent should probably do this, that way everyone will pick it up.
 xxxxx@xxxxx  2001-10-22
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang