Adding rows to a JTable

后端 未结 3 1495
悲&欢浪女
悲&欢浪女 2020-12-03 01:46

We have a simple project where we read data from a socket and we want to populate a table with the coming data, but we can\'t find a way to add rows to a yet created J

3条回答
  •  借酒劲吻你
    2020-12-03 02:38

    You should create a custom TableModel. A JTable doesn't actually store the rows, it always delegates that to a TableModel. To help you implementing it, you should make use of AbstractTableModel. Don't forget to call fireTableRowsInserted() every time you add rows. For better performances if you add a lot of rows, try to batch the updates and add many rows at a time.

提交回复
热议问题