File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTable Binding Update Bound Item List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable Binding Update Bound Item List" Watch "JTable Binding Update Bound Item List" New topic

JTable Binding Update Bound Item List

Carlos Conti
Ranch Hand

Joined: Apr 21, 2010
Posts: 131
Hi all,

I have a JTable with a bound List<A>, with bindings setup with Netbeans6.8. My problem is the following: I succesfully bind the instances of A in the list, but when editing its properties, the model is successfully updated, but the table is not refreshed. Before starting a thousand workarounds I would like to ask you if there's any neat method to set a more accurate update strategy (I already set Read/Write, but of course for the list, not for the underlying instances).

I hope I made myself clear.

Best regards and many thanks in advance.

Roberto Perillo

Joined: Dec 28, 2007
Posts: 2270

Howdy, Carlos!

Well, personally, I don't like NetBeans (this is just, of course, a personal opinion), so I don't know exactly how your environment is. But the thing is, in order to refresh the JTable so it displays the data of your TableModel, you should call fireTableDataChanged() after updating the TableModel.

Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Carlos Conti
Ranch Hand

Joined: Apr 21, 2010
Posts: 131
Hi Roberto, thanks for the quick answer....

the problem is that since I am using bindings, if I retrieve the tablemodel I get an instance of an inner private class of the JTableBinding class (org.jdesktop.swingbindings.JTableBinding$BindingTableModel)... to which I am not gaining access, therefore not being able to fire the update as you said... hmmm.... any ideas?

Hoping that the retrieved object was a descendant of the DefaultTableModel, I tried to call that method via Reflection, but got the NoSuchMethodException.

I agree. Here's the link:
subject: JTable Binding Update Bound Item List
It's not a secret anymore!