Hi all, I'm starting to use AbstractTableModel to customize a JTable model. The problem appears when you add a record from a ResultSet to JTable object.
I've managed to insert records, but empty, I need that for every column I can see the data is there.
Leave some code I have been writing ... the method to insert records in JTable is called "insertEmptyRow" (for now).
I need some opinion that can make changes to the code of this method so you can get to see all the data in a record.
First of all, you should separate the code dealing with JDBC and the GUI code separately. Using the ResultSet directly within the GUI is not a good idea.
As for the table model, I would ask you to first look at the tutorial to understand more about tables and models. Once you get an understanding, you can work with it.
SCJP 1.4, OCMJEA/SCEA 5.0.
posted 6 years ago
I was reading the tutorial several times , always work with DefaultTableModel , this class has a " insertRow " method that handles so almost " automatic" load of records in the JTable .
The issue with AbstractTableModel is I do not understand how it works ( I have a habit of investigating from scratch how things work ) and I have some very specific questions.
When I assign a "custom model " ( inheriting from AbstractTableModel ) to a JTable that is what happens internally ?
Obviously the class structure is the same there is a constructor and methods that are overwritten , so I do not understand is that method I call to get the records .
I was thinking an alternative , use the " getValueAt (int rowIndex , int columnIndex )" method but leading the " wrapper " class and calling Getters and Setters of the same methods. But I still have the same problem as I insert in the JTable ?
From already thank you very much for your patience and for answering .