Forums Register Login

JTable + JScrollPane manipulation

+Pie Number of slices to send: Send
I need help is changing the view area of my JTable. My JTable is inside a JScrollPane. I want to show the end of my JTable instead of the beginning.
+Pie Number of slices to send: Send
I did something like this many years ago. If I remember right I think I got the vertical scroll bar from the JScrollPane and then used the setValue() method of the JScrollBar to set it's position.
I also remember that it didn't work on a scroll pane wrapped around a JTextArea. I had to set the curser in the JTextArea to the end of the document because the JScrollPane would automatically scroll to wherever the curser was. If you see similar behavior with your JTable then maybe try seting the selected row to the end of your JTable.
Hope it helps.
+Pie Number of slices to send: Send
Hi, Greg
I am also facing the same problem. However, I tried the setSelectedRow() method. In this case cursor moves to that row, but Jscrollpane does not scroll to that place.
May be TextArea & JTable have different behavior with JScrollpane.
Manoj
+Pie Number of slices to send: Send
I tried the following, it works
int lastIndex = tableModel.getRowCount() - 1;
Rectangle rect = histLsaTable.getCellRect(lastIndex, 0, true);
histLsaTopScrollPane.getViewport().scrollRectToVisible(rect);
Thanks everyone.
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1120 times.
Similar Threads
JTable
JTable
JTable
JTable
Jtable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:41:48.