Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is a table listener needed to update a JTable?

 
Sean Gildea
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I've been having a problem refreshing data in my JTable, and everyone says to use

fireTableDataChanged();

However, the API doc for this method says

void fireTableDataChanged()
Notifies all listeners that all cell values in the table's rows may have changed.

So heres my question: Do I need to register/create a table listener? And if so, how do I do it?

Code example would be perfect!

Thanks!
 
Clivant Yeo
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sean,

Two TableListeners are added implicitly to the JTable when you created it, as such there is no need to add your own Listeners, unless you want other custom actions to be performed when the fireTableDataXXX method is invoked.

Regards,
Clivant
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic