JTable and database
I have a question: i premise that i've already searched in the forum.
I have a JTable, created on my own TableModel. I can't post any code because i'm not at home and i need to urgently reach a solution, so here i am. I know that JTable works this way:
JTable accept these parameters: String (which is the matrix that contains data) and String (which contains column names).
I need to populate the JTable from values coming from the database. Ok, i've got the query running good and the correct resultset that gives me the data i need. The question is: how can i fill the matrix String (the first parameter of the JTable)? I have to create a 'for' iteration? Or can i fill the matrix in the 'while' iteration from the resultset? I tried in a lot of ways, but i can only print the last of the resultset.
Thanks a lot in advance!
Ps: Happy new year to everyone! :)
First off, I would extend a DefaultTableModel object as my table model, and then I'd use its addRow(...) method to add information to the table when / if it becomes available. So the key is that you're adding information to the model not the table, and you're using a Model object that has methods that will accept a new row.