Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I call this JTable TableModel method?

 
Sean Gildea
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I call the method addCruiseListing defined in my custom TableModel so my JTable displays data?

Also, how can I call it later on as well?


 
Matthew Taylor
Rancher
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would create the TableModel as an attribute in the TableDemo class.

Declare the MyTableModel so the whole class can see it.

Create the MyTableModel object and send it to the JTable for construction.

Now you can create a getter method in the TableDemo class that returns the model it's using:

And just use this line wherever you want to use a MyTableModel method:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic