Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JLists  RSS feed

 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I have three JLists in three individual JScrollPanes. All the objects in the JLists are equal in size

What i need to is when i select an object in a certain JList, the index second and third JList is selected and also the JScrollPane is supposed to automatically scroll to that position so that the selected indices are visible by the user

This is how far i have gotten so far.
The selection part is already done but i can't get the individual JScrollPanes of the second and thirs JLists to scroll to the part that is being selected in the first JList

I am listing what is in the ListSelectionListener



Please assume the first JList is called List1, the second List2 and the third List3

Some sample coding would be helpful

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method you need is ensureIndexIsVisible(int idx) in the JList class. Just pass it the first index of your range and it should work.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!