Hi, Could you, please, tell me if there is any way to update (add a row) a JTable ? Something like addRow() ? Or a tip , link to some web page which gives a tutorial on it ? I need it for a JDBC application. Thank you very much. Cata Lin.
The JTable itself has no method for this - look instead to the TableModel which you have associated with the table. If you've used a DefaultTableModel, it has methods addRow() and insertRow() which should accomplish what you need. If you've used a Vector of Vectors instead of a TableModel, you can use the add() and insert() methods of Vector (be sure to create a new Vector to represent the row, since the table model is a Vector of Vectors). If you're creating your own class which implements TableModel, then it's up to you to provide a method to add/insert rows if you desire, depending on what sort of data structure you're using. (Note that the first two suggestions are likely easier.) The Java Tutorial has a page here on how to use tables. I don't see any examples of adding / inserting rows there offhand, but they might be hiding. Good luck.
"I'm not back." - Bill Harding, Twister
Joined: May 11, 2000
Hi, Thank you, Jim, I used a DefaultTableModel in the end, and insert row was good because it updated the table automatically. Many thanks. Cata Lin.