Good day to all! As I know, when creating a table, it is possible to overload to send a two-dimensional data array and one-dimensional with column names.

JTable table = new JTable(data,headlines); 

Is it possible to somehow return NEW table data to an array?

  • What is new data? - Mikhail Vaysman

1 answer 1

You need to implement AbstractTableModel or DefaultTableModel and at that moment when you change data from outside, call fireTableDataChanged . Override isCellEditable for editable cells. Override setValueAt to change data and call fireTableDataChanged .

You will pass your model to the JTable and then it will be updated automatically.

  • Do you mind if I contact you in HP with questions on your answer? I don’t know some of the methods, I’ll figure it out now - Vladislav Solopov
  • I answered your question? if so, take it. - Mikhail Vaysman
  • I do not know, I realize - Vladislav Solopov
  • @Mikhail_Vaysman I don’t understand how it concerns isCellEditable (checking if a cell is editable) and setValueAt (for entering values ​​in a cell) and the redrawing method fireTableDataChanged to the task? I do not see the connection :( I need to save the new data to the array - Vladislav Solopov
  • one
    If you do not have all the cells editable, do you need this how-to specify the table? And if your data has changed, then you need to redraw the table? - Mikhail Vaysman