If I want to use a JTable
in Java it seems to me for adding rows and doing alters from behind a button or so I always have to use a TableModel
(this could be the default one or one created by your own) But my question is: Why do we have to use this. I can't find this in any of the posts I saw. Can someone explain how this works and why it is necessary? And why we can't just add rows to the JTable
without a model.
It seems to me that if you want to just show a few records but at creation you don't know all the rows yet it would be easier to just do something like a table.add()
to add the row.
You can create the table with data inside without a model attached to it. So why not add data?
Or am I just wrong and can you add also data without a model?