Put the elements of the record (rs) into a Vector (you could also build an array of Objects) and then you can add the vector to the table. Read the documentation for JTable and also the tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
Here is documentation for Vectors:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Vector.html
would an ArrayList work as well? I do knoe the diffrenec between a vector and arraylist. Thats why I'm asking if that would work as well. However I was unable to fins the methos to put text in a jtable. When I try to set the text in a JTextField it would not let me. I was think *** it was for the same reasons why it wasn't working
This actually my first time writing code in netbeans. For my school capstone project, we are writing something like Microsoft Money. Stop assuming. This my first time tryin to make a Table Model. I juts need a little. The rest of my team have decided to use netbeans therefor I have to use netbeans. So ar eyou able to help me? Point me in the right directon? the rest of the code but I can't get the table to show in netbeans All the GUI seem to explicitly handle by NB
You can certainly use an ArrayList, its just not preferred.
Just loop through your List and add a new row:
java.util.List<SpecialClass> specialClassList = // Some special ArrayList you've constructed :)
AbstractTableModel tableModel = new AbstractTableModel(0, 0);
JTable table = new JTable(tableModel);
tableModel.addColumn("Column1");
tableModel.addColumn("Column2");
for (SpecialClass c : specialClassList)
tableModel.addRow(new Object[]{c.getFirstItem(), c.getSecondItem()});
And continue to use the tools you have available to get your project completed. Netbeans is a powerful tool, and despite the negativity, the more beginners we have programming with it, the better Java will become!
I remember doing something similar with .NET and it was extremely complicated because I had to set up a relation between a table and a database, and the IDE would do everything else. Sometimes the IDE is harder to figure out than the raw code.Good luck!
-FBL