How to scroll to last row in a JTable

前端 未结 4 1196
梦谈多话
梦谈多话 2020-12-14 22:34

I am trying to use JTable in the way where new data record are added to the end. The strange thing is the scroll bar does not go to the end of the table; instea

4条回答
  •  温柔的废话
    2020-12-14 23:24

    Why not call fireTableRowsInserted upon updating in your TableModel implementation?

    I usally have something like below in my TableModel implementation:

    public void addRow (MyDataType valToAdd){
    rows.add(valToAdd);
    fireTableRowsInserted(rows.size()-1,rows.size()-1);
    }
    

提交回复
热议问题