• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DefaultTableModel vs Extending AbstractTableModel

 
Vikas Sood
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
Can anybody pitch in with some thoughts on this ,I am a little confused on this.
Regards,
VikasSood
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vikas
Are you about to code for this, and are trying to work out which one to do? Or are you documenting, and trying to work out why you did what you did?
There are two conflicting requirements that come into play here.
  • we should not write our own code if there is something that works already in the standard API
  • we should try and make the GUI as user friendly as possible


  • According to the first, we should use the DefaultTableModel.
    However to meet the standard convention of having numeric fields right aligned, we would have to create our own TableModel.
    Does this give you something to start thinking about?
    Regards, Andrew
     
    Vikas Sood
    Ranch Hand
    Posts: 109
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Andrew,
    Thanks again for answering, I have already done the coding part.
    Why i am asking this question now is that i am documenting my choices at the moment.I have not done anything as you sugessted about right aligning integers etc. I extended AbstractTableModel and written my own TableModel class basically for better implementation of MVC in my assignment.I have added 2-3 methods apart from the required methods,these are for loading content and schema on to the table Model as a result of an event fired by Model class to its listening Views. There is one method which helps Controller receive a record information from View.Thats abaout it, will it be ok to just document this.
    Kindly comment.
    VikasSood
     
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander
    Pie
    Posts: 12007
    215
    C++ Firefox Browser IntelliJ IDE Java Mac Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Vikas,
    Perhaps you could also write something about why you couldnt (or didnt want to) use the DefaultTableModel. That is, what would have been the implication for the MVC if you had not used it?
    Once you have a reason for using something, and an explanation of why the alternative would not be ideal for you, I think you are covered.
    More reasons for using your own TableModel can be found in Emerson Dunne's post in this thread.
    Regards, Andrew
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic