• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scrolling a JTable

 
George Hamilton
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a problem trying to scroll my jtable to the last inserted entry (at the bottom) using the following code:

Rectangle rect = table.getCellRect(model.getRowCount() - 1, 0, true);
table.scrollRectToVisible(rect);

It works 90% of the time, but sometimes it refuses to scroll to the last entry. The row count is correct and I've tried repainting the scrollpane and table after the above call without success.

I'm using Java 1.4.2 on Suse Linux 9.1.

Any ideas?

George
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but sometimes it refuses to scroll to the last entry


what does it do instead ?
 
George Hamilton
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It scrolls to the second last entry.
 
George Hamilton
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally solved this issue with calling the scrollRectToVisible in SwingUtilities.invokeLater call.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!