Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

scrolling JTable to make cells visible  RSS feed

 
Nadinha Jovan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code I am using to scroll JTable to its last cell and to make that cell visible. For some reason however, that cell is selected but the table does not scroll to it to make it visible. Can anyone help and tell me what I am doing wrong?

JTable table = codeEntryPN.getCodeDescriptionTable();
TableModelDataCapture tableModel = (TableModelDataCapture)table.getModel();

//adds a row of data to model to the end and fires row inserted
tableModel.addDummyRow();
int lastRow = tableModel.getRowCount() - 1;
table.setRowSelectionInterval(lastRow, lastRow);

//makes the newly added row visible
table.scrollRectToVisible(table.getCellRect(lastRow, 1, true));

thanks
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!