I am having a problem understanding how to get a result set into a JTable. I have seen many posts and webpages that describe using a table model to accomplish this, but I am lost as to how that should work. Can someone describe the basics of how to accomplish this?
What you need to do is create a class that subclasses AbstractTableModel. If you take a look at the JTable Tutorial from Sun they show you how to do this. Then all you have to do is fill that model with the data from your database. Give that a go and if you are still having problems lets see some code and help you out a bit.
Here is my basic design so far... 1. CLASS VAICon - Use this class to setup a connection (drivers and such). 2. Class BOMData - Extend the VAICon class because of the specific data produced from the query(I will repeat this for each type of data). 3. Use BOMData resultset to create 2 vectors (data and labels)to create a JTable.
The part that confuses me is I may need a class for the abstract table model, does this read data from the BOMData class result set... or the vectors I would need to create (passed in). Also using this type of setup...should I make a table model for each class that extends VAICon?? I am dealing with a ERP system with many groups of data so in the end would have something like this???
1. VAICon (connection stuff) 1. BOMData (extends connection gets result set makes vectors) 2. BOMModel extends AbstractTableModel(constructor takes vectors from BOMData) and does ??? 3. BOMTable extends JTable(use BOMmodel)
Am I on the right track here? Or would I only need one table model for all data that I get using VAICon and an extended class??