views:

2142

answers:

2

I have a JTable that is within a JScrollPane. Rows are added to the table at runtime based on events that happen in my application. I want to have the scoll pane scroll to the bottom of the table when a new row is added to the table.

For JLists There is the ensureIndexIsVisible() that forces a particular index in the list to be visible. I'm looking for the same thing but for a JTable. It looks like I might have to manually move the scrolling view on the scroll pane but I figured there had to be an easier way.

+7  A: 

See this example : http://www.exampledepot.com/egs/javax.swing.table/Vis.html

Pierre
A: 

JList internally use scrollRectToVisible and specify the coordinates to scroll to. I think you will have to recode a similar functionality for JTable.

Valentin Rocher