1
votes

one question with the java jTable class. Actually I am not a Java programmer and just now using Java to design a GUI in Matlab. What I've done is:

  • A jTable is built into a Matlab GUI.
  • I used/called a RowFilter in jTable, which can make the jTable to show the filtering results.
  • Then from the results in this filtered view I used the removeRow method from table model to remove one or several selected rows.

The problem is that everytime if I remove a row, the table content refreshs itself as wanted, but the scroll bar jumps back to the beginning.

Does anyone know how to inhibit this jumping and keep the original view of jTable? Because this helps me not to have to scroll back to find the original position where I started the deleting.

Thank u for ur advice and help.

1
sounds like the tableModel is firing an incorrect event (f.i. dataChanged instead of rowDeleted)kleopatra
just checked: works fine with core JTable and DefaultTableModel, so there's something wrong with your code (@trashgod: indeed to manual interference needed :-)kleopatra
Thank you for your advice. Can you tell me how to check and correct it where was wrong ?OISS
@trashgod: meant no manual ..kleopatra
register a tableModelListener and see what it fires on deleting a rowkleopatra

1 Answers

1
votes

Invoke the table's scrollRectToVisible() method; pass it the Rectangle returned by getCellRect() for the desired row.