• Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving Scroll Bar in Scroll Pane when new Line added to JTable in ScrollPane  RSS feed

 
Jeff Holmes
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a ScrollPane that contains a JTable, I add a new line to the Jtable and the viewable area is to big, so the scroll area stays at the top of the jTable. I want to move to the bottom of the scroll pane as soon as the line is added. Here is the line that I have:
jScrollPane1.getVerticalScrollBar().setValue(jScrollPane1.getVerticalScrollBar().getVisibleAmount());
I have also tried:
jScrollPane1.getVerticalScrollBar().setValue(jScrollPane1.getVerticalScrollBar().getMaximum());
This does not work right after adding the line to the jTable. But I do hava a JButton when action is performed runs the same code, and WORKS! I can not figure this out... Any help would be appreciated, Thanks, Jeff
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!