Is it possible to replace the entire TableModel in an existing JTable or do I have to recreate the JTable?
We can add or insert a JButton to JTable cell by customizing the code either in DefaultTableModel or AbstractTableModel and we can also customize the code by implementing TableCellRenderer interface and need to override getTableCellRendererComponent() method.
To completely remove the selection capability from JTable component we can change its focusable state to false by calling the setFocusable(boolean focusable) method.
getModel(); tableModel. setRowCount(0); and then restructure the table model again so it will refresh the jTable.
You can set a new model using the JTable.setModel()
method
Check the Javadocs for details
When you change the model you are stuck with old column titles. getColumnName()
only gets called on initialization.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With