Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

generating JTable on the fly

Status
Not open for further replies.

cram81

Technical User
Dec 27, 2003
29
GB
hi

ive been trying to code my Jtable do that it updates on the fly as opposed to hard coding it so it is populated on start up...

so far im am initailsing it by :

table = new JTable(mydb.getAllEventQuery(), headings);

where mydb is a class that does all my database query processing and getAllEventQuery returns a Object[][],

headings = {"username","event_id","tsStart","tsFinish");

i have this in an buildGUI method for my app which only gets called once...
I want to have an actionListener to a button so that when pressed the contents of table is re- populated ... but when going through the java API i can't seem to find any methods for JTable which set the data like in a JList where you can do something like:

myList.setListData(vector v);


is there a similar method for JTable ?? or do i have to abandon the way im doing it and go down the more complicated route of defining my own table model??

thanks

mark
 
I think you answered your own question :

You can use "DefaultTableModel" or extend "AbstractTableModel"
DefaultTableModel has a 2 methods "setDataVector(...)"
But even extending AbstractTableModel is not that difficult.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top