Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Appending rows to the end of a JTable
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Hikaru79




PostPosted: Sun Dec 12, 2004 6:30 pm   Post subject: Appending rows to the end of a JTable

I'm busy working on the infamous Database java project. I decided to go with Swing for it, and most of it has been rather smooth. However, I do have this hiccup. I have a JTable that takes the 2d array I generate and displays it. The user has the choice to add fields to the database either from file or manually. The values get added to the array no problem. here's where the catch is-- I have the updated array, but how to update the table with it? I've gotten it working so far by simply creating a NEW table with the NEW array and adding it to a NEW JScrollPane. However, this is probably horribly inefficent and there has to be a way to simply have the JTable check the array it was passed again, and redraw itself. Can anyone give some example code of this working out? ATM, it's going way too slow for comfort =/

Thanks! Very Happy Any and all help greatly appreciated!
Sponsor
Sponsor
Sponsor
sponsor
TheZsterBunny




PostPosted: Sun Dec 12, 2004 9:41 pm   Post subject: (No subject)

lolololol

Hikaru, I've hit the same problem, and after smashing my head against it for the better part of 6 hours this morning, I've just decided to switch to a 'dos like' interface.

However, I have a book to 'lend' you if you so desire.

-Z
Martin




PostPosted: Tue Dec 14, 2004 3:40 pm   Post subject: (No subject)

Why not just use a tree?
TheZsterBunny




PostPosted: Fri Jan 07, 2005 5:33 pm   Post subject: (No subject)

coz trees are plants. duh! we want code.

Rolling Eyes

-Z
rizzix




PostPosted: Fri Jan 07, 2005 6:45 pm   Post subject: (No subject)

hmm y dont u clean up the table contents and re-fill it with new values ( a new array). this is a good alternative.

but still inefficient.. the most efficient method is to update the Vector the table uses and the contents of the JTable right away. that is simply input a new record at so-and-so position in the Vector the in the respective position in the JTable etc likewise.

EDIT: to do this you might want to use the DefaultTableModel as opposed to an array.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: