• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Tom Landry
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Rob Camick
Ranch Hand
Posts: 2536
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic