aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DefaultTableModel and DefaultComboBoxModel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "DefaultTableModel and DefaultComboBoxModel" Watch "DefaultTableModel and DefaultComboBoxModel" New topic
Author

DefaultTableModel and DefaultComboBoxModel

Sam O'Neill
Ranch Hand

Joined: Nov 25, 2002
Posts: 57
Hi Everyone!
Has anyone used either the DefaultTableModel or defaultComboBoxModel in their GUI implementations? I have read several threads where people have said that Vectors are outmoded and are not too desirable due to their synchronization which I don't need but at the same time to implement my own table and combobox models could be construed as reinventing the wheel by Sun if the default versions could have been used.
My reason for providing my own table model was that I want to just pass the DataInfo[] objects array straight back to the GUI and have a method in my table model to receive it with the following signature:
public void setDataRecords(Datainfo[] data)
I can then extract the headers and the data into my model in one go. I was planning to store the data internally in the model in an array as I will never be adding a record one at a time so no need for dynamic resizing and no need for converting between a List and arry to index into it.
I want to do the same with my combobox model for the origins and destinations so they can be assigned all at once each time with a method call:
public void setListItems(Set items)
Again I have no need for dynamic resizing of the list so could store in an array.
The point is I COULD just use the Default models and pass the data in the manner expected by them but then they use Vectors and provide a whole heap of functionality I neither need nor want to encourage such as dynamic resizing.
Does anyone have any thoughts on this as don't want to reinvent anything but at the same time want something more tailored to my application's needs.
Many thanks in advance
Sam
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Use DefaultTableModel, or should I say extend it and make the necessary changes to make it use the DataInfo[] to show the data in the JTable.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Sam O'Neill
Ranch Hand

Joined: Nov 25, 2002
Posts: 57
Thanks Mark - so you think that the use of Vectors is perfectly ok?
Sam
 
 
subject: DefaultTableModel and DefaultComboBoxModel