• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Programatically scroll up or down jtable

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I'm having serious issues right now with a JTable inside a JScrollPane.

i have some methods that returns different indexes (rows) that i select programatically in a JTable and the problem is that sometimes
it goes beyond of what i can see, like, the row gets selected but the scrollbar won't follow up.

i've searched up in google and saw several different methods but those were extremely complex and for stuff i don't need.

the simplest solution i found is this:



but it just doesn't do anything.

My table (tInfo) has only two columns so no horizontal bars, just vertical. What can i do to align the scrollbar with the currently selected row in my table? :C

EDIT:

Found a solution using scrollPane.getVerticalScrollBar().setValue();
in another thread, i didn't even notice there were like 3 more threads about the same, just different kind of code used in each haha. sorry ><
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Found a solution using scrollPane.getVerticalScrollBar().setValue();
in another thread, i didn't even notice there were like 3 more threads about the same, just different kind of code used in each haha. sorry


No problem, thanks for updating the thread.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

M Ramirez wrote:the simplest solution i found is this:



but it just doesn't do anything.



Your selected row isn't currentIndex, it's searchIndexes.get(currentIndex). Once oyu correct that, I think you'll find that scrollRectToVisible works as documented.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!