• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about this DefaultTableModel sample and associated function incorporated into its statement

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Found a really good example on working with the DefaultTableModel but have a question on this function that is created.

This may be more of a general question but figured the sample is geared toward Swing components and figured I would post it here.



Full code is listed below.

I am familiar with ActionListeners as well as inner and classes and anonymous classes, but the above code is a bit unique to me.

It almost seems like when the model variable is instantiated that a public function named getColumnClass is dynamically being created.
Also, I don't see the getColumnClass being called. Is it something that gets call implicitly?

I appreciate any input and would be interested in explanation as well as links to documentation that discuss this topic.

 
Tom Landry
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, did some more searching.
Apparently the geColumnClass is part of the abstract class AbstractTableModel and DefaultTableModel is the subclass.
So, if I follow, basically the code in question is overriding the abstract method getColumnClass which has been defined in DefaultTableModel.

Is that a correct assumption?
If so, my one questions is still about how this function is getting invoked.
 
Rancher
Posts: 3324
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is that a correct assumption?



Yes.

If so, my one questions is still about how this function is getting invoked.



Methods from JTable will invoke this method as required. For example, the table needs to know the type of data in each column so it can use an appropriated renderer to paint the data in the cell of the table.
 
reply
    Bookmark Topic Watch Topic
  • New Topic