aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Question about this DefaultTableModel sample and associated function incorporated into its statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Question about this DefaultTableModel sample and associated function incorporated into its statement" Watch "Question about this DefaultTableModel sample and associated function incorporated into its statement" New topic
Author

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

Tom Landry
Ranch Hand

Joined: May 26, 2013
Posts: 76

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

Joined: May 26, 2013
Posts: 76
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

Joined: Jun 13, 2009
Posts: 2215
    
    7
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.
 
wood burning stoves
 
subject: Question about this DefaultTableModel sample and associated function incorporated into its statement