• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

JavaFX Listview Item scrollTo() issue

 
Greenhorn
Posts: 8
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

I have a Listview with its items from a ObservableList<CustomItem>.
The cell factory is made with a CustomControl based on an AnchorPane, and displays multiple labels. Those labels's textProperty are bind to the properties of CustomItem class.
My problem is that because of the height of the CustomControl (the cell of the listview) is sometimes displayed partially in the listview. When I click on such an item, which is not entirely in the view, I want to scroll the listview as the cell to be entirely in the listview. But the scrollTo() method will scroll the listview as the selected item will be in the top of the list. I want only to bring it into view, not scrolling it to the top of the list. So, if my control is in the bottom of the listview and supposing its height is 80px and it is only 20% in the view of the listview, to be able to scroll the listview to see the rest of the 80%, and to be align to the bottom of the listview. If it is in the top, and partially outside of the listview viewport to align to the top of the listview. And if it is inside listview, and I see it entirely, to do nothing.
I think I have to calculate the position of the cell in the listview viewport.
Or someone, do you know a library which have this ability?

Sorry for my english 😁
 
Bartender
Posts: 303
12
IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To the best of my knowledge (could be wrong) I don't think that'll be possible for "free" out of the box.

Depending on your design and the dimensions of what you're working with maybe you can do a simple calculation to calculate a better "scrollto" parameter, but if not you may be better off with a different design (this mostly comes to mind because I have a personal dislike for very "tall" rows in list controls, due to stuff like this).

Just one of those things with UI SDKs, when you start getting very specific about their behavior you're rolling the dice as to how well they can support whatever hackory needed to do it, you might be at that point here.
 
permaculture is giving a gift to your future self. After reading this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic