JDK-4403697 : JList returns -1 for firstVisible, lastVisible. ensureVisible not working
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_7
  • CPU: sparc
  • Submitted: 2001-01-11
  • Updated: 2001-01-24
  • Resolved: 2001-01-24
Related Reports
Duplicate :  
Description

Name: boT120536			Date: 01/10/2001


(filed against kest-sol-fcs)
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)


A JList, in a JScrollPane, in a box, in a JPanel, with
20 some items:
  a.) Returns -1 from getFirstVisibleIndex() when the
      first item in the list is displayed.

  b.) Returns -1 from getLastVisibleIndex() when the
      last item in the list is displayed.

The application has two lists of terms, where each list
is in a different language. The goal was to keep the two
lists synchronized after selections, yet independently
scrollable. It seemed that ensureIndexIsVisible() would
be the right way to do that. But even after correcting the
values returned by getFirstVisibleIndex and getLastVisibleIndex
in one list, using those values as arguments to ensureIndexIsVisible
in the second list has no effect.

Only ensureIndexIsVisible() on the selected-item index has any
effect, but the effect is limited -- the lists are not fully
syncronized.

Possible solutions:
  added API: ensureRangeIsVisible(firstIndex, lastIndex)
    --this API would allow precise positioning of the displayed
      values
      (OR)
  added API: ensureIndexIsVisibleAtPosition(index, lineNumber)
    --again, this API would allow precise positioning of the
      displayed values.

As a documentation exercise:
  --if -1 can be returned by the visibleIndex operations under
    any circumstances, those circumstances should be documented.
  --the effect of ensureIndexIsVisible should be documented.
    ..will the minimum amount of scrolling take place?
    ..will the item be shown at the top of the list, or at the
      bottom?
    ..will it be shown at the top if it was above the current
      view, and at the bottom if after?
    ..will multiple calls have any effect?
      for example, will ensureIndexIsVisible(0) followed by
      ensureIndexIsVisible(20) always ensure that item 20 is
      at the top of the list, as opposed to it being at the
      bottom in some circumstances? Or are multiple calls
      ignored in favor of the last? (It appears that may be
      the case, at the moment, in which case the argument for
      the additional APIs is all the stronger.)
(Review ID: 111391) 
======================================================================

Comments
WORK AROUND Name: boT120536 Date: 01/10/2001 Haven't found one yet. ======================================================================
11-06-2004

EVALUATION Need a test case that exhibits this behavior, have emailed submitter for more information. scott.violet@eng 2001-01-19 I have attached the test case from Eric. After talking with Eric, and looking at the test case the only bug is that getFirstVisibleIndex will return -1 if you have a Border around the JList. This was fixed as part of 4308384, which I am now closing this as a duplicate of. scott.violet@eng 2001-01-24
24-01-2001