When should I rather implement TableModel and when should I extend AbstractTableModel?
When should I rather implement TableModel
When you need a complete clean sheet implementation of the table model and/or you have to provide something that by the nature of your model doesn't exists yet or doesn't fit.
and when should I extend AbstractTableModel?
When you can reuse the existing structure and methods provided by the abstract class and/or it would easier for you to implement it.
The idea is, if you can re-use it, do so. If you can't, implement from scratch.
By inheriting AbstractTableModel you'll be imlementing the TableModel interface anyway, it just will be easier.
AbstractTableModel
has implementation for the handling of TableModelListeners
, including the firing of TableModelEvent
s. If you want to handle that yourself, then there really is no reason to extend. Outside of that code, the other code doesnt add any benefit other than the stubbing out of methods declared in the interface.
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