Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DefaultTableModel and DefaultComboBoxModel

 
Sam O'Neill
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sam O'Neill
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark - so you think that the use of Vectors is perfectly ok?
Sam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic