I'm unsure of how to approach getting the db records to display in the JTable. I've written some sample code to get the records back from the database as an array of DataInfo objects. At that point, the only way I can think of to get the field values within the DataInfo records into the JTable (via the constructor: ) is to overrride the 'toString' method for a DataInfo object to return a delimited string for the values in the internal FieldInfo array. I can then use a multi-dimensional array of Strings as the 'Object' parameter in the constructor. What do you think?
Check out custom table models, you will find information in the jtable api documentation on sun's site. You can then create your own constructors and methods as needed to meet your needs. -Matt
-Matt<br /> SCJP2<br /> SCJD
Joined: Jan 29, 2002
I thought there had to be a better way. I REALLY appreciate the response. Thanks! CG
Joined: Feb 24, 2002
You can extend the AbstractTableModel, and do the same thing, but I think this is your best bet. Remeber part of the requirements say to not rewrite something that sun already provides for you unless it's absolutely necessary, so if you can justify it go for it, but I would try to take advantage of the MVC design pattern sun already has in place for tables. Just my $.02 Thanks