Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8114498

Calling scrollTo on ListView immediately after adding to list causes scrollbar to behave incorrectly



    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0
    • Component/s: javafx
    • Environment:

      FX 2.0 beta b32


      I am trying to achieve the effect of having the listview automatically scroll to the bottom as new items were added to it. After calling listView.getItems().add(), I attempt to call listView.scrollTo(listView.getItems().size() - 1); I realize now that this may not be feasible because you're not guaranteed that the display has been updated to reflect the addition of the new item. In any event, calling the scrollTo method in that manner is causing the scroll bar to behave such that you cannot scroll it with the mouse, and it only appears to have two positions if you use the scroll bar arrows or the mouse wheel to scroll it (the very top and the very bottom).

      I'm pretty sure that prior to build 32 it was not locking up the scrollbar when I called scrollTo and I think that generally it had the effect of causing the list view to scroll to new items as they were added at the bottom. Now it does neither.

      Note that if you call scrollTo later, as in attach it to a separate button like I've set up in my example app, that it works fine. The problem is specific to calling scrollTo immediately after adding an item to the ListView. I also tried calling scrollTo on size() - 2, which should already be on screen but that also does not work. It seems like it might be necessary to implement some sort of "requested scroll index" in the list view and then scrolling to that view next time the control is repainted (and then clear out the index).




            jgiles Jonathan Giles
            kmcintyrejfx Kyle McIntyre (Inactive)
            0 Vote for this issue
            2 Start watching this issue