I have a JTable embedded in a JScrollPane.
Through code, I want to select a specific cell in the table and make sure
it scrolls into view.
Here is my code (note: my JTable only has one row, but a large number of
columns):
int index = 5; // column that I want to show
tblDiscContent.getColumnModel().getSelectionModel().
setSelectionInterval(index, index);
scrollDiscContent.getViewport().scrollRectToVisible(
tblDiscContent.getCellRect(
0,tblDiscContent.convertColumnIndexToView(index), false));
The last statement should scroll the cell into view, but it doesn't. It
scrolls too far to the right, leaving my cell hidden to the left. The
amount of error does is not constant and depends on which cell I try to select.

Signature
Josef Garvi
"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/
new income - better environment - more food - less poverty
Josef Garvi - 27 Apr 2005 14:04 GMT
I found a working solution.
http://www.javakb.com/Uwe/Forum.aspx/java-gui/3812/how-to-make-of-a-specific-row
-the-first-row-toprow-in-the-visible

Signature
Josef Garvi
"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/
new income - better environment - more food - less poverty