JDK-4198834 : ListDataEvent.getIndex0() should be <= getIndex1()
  • Type: Bug
  • Status: Resolved
  • Resolution: Fixed
  • Component: client-libs
  • Sub-Component: javax.swing
  • Priority: P4
  • Affected Version: 1.2.0
  • OS: generic
  • CPU: generic
  • Submit Date: 1998-12-20
  • Updated Date: 2017-05-16
  • Resolved Date: 2003-06-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
5.0 tigerResolved

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.

(Review ID: 48508)

CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b09

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); } ======================================================================

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