• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing getModel() return value / compiletime/runtime understanding  RSS feed

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I've got a TableModel with a method addColumnInd:

This works fine:

But this

causes:

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
The method addColumnInd() is undefined for the type TableModel


Why? I already asked on IRC, and they said something about compile time and runtime. But I didn't understand it. Sure I've read about it, but javadoc says:
getModel()
Returns the TableModel that provides the data displayed by this JTable.


So I expected model, which is an instance of MyTableModel! The javadoc says nothing like: " Attention: getModel() does only work for the Defaultmodel.?" This is misleading for me.For what should this method be? Please enlighten me.What does "Returns the TableModel that provides the data displayed by this JTable" mean, and why was this error thrown?
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The object returned by getModel() is of type TableModel, which does not have a method called addColumnInd().

You ought not to run anything which the IDE says has a compiler error, but correct the error first.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!