Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Programatically scroll up or down jtable  RSS feed

 
M Ramirez
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 ><
 
Tony Docherty
Bartender
Posts: 3264
81
  • 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.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!