JDK-4198834 : ListDataEvent.getIndex0() should be <= getIndex1()
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 1998-12-20
  • Updated: 2017-05-16
  • Resolved: 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 Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
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
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b09
24-08-2004

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

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
22-09-1999