2

I've got a java.util.List bind to a JTable, if I want to refresh the table using

  1. bindingGroup.unbind();
  2. bindingGroup.bind();

I get this exception:

Exception in thread "Thread-8" java.lang.UnsupportedOperationException: Can not call this method on a managed binding

relative to the 2nd line above.

Below more specific code:

    new Thread(
            new Runnable(){
                public void run(){
                    fireProgressBar(true,"working...");
                    controller.doSmoething();
                    fireProgressBar(false,"");   
                    bindingGroup.unbind();
                    bindingGroup.bind();
                    jTable1.revalidate();                        
                }
            }                
            ).start(); 

fireProgressBar is a simple method that I wrote for jProgressBar activation, nothing here is involved in binding.

the bindingGroup.bind() call throws the exception above.

I tried also with SwingUtilities.invokeLater instead of new Thread(....).start(); but I get the same issue.

Thanks.

mKorbel
  • 109,525
  • 20
  • 134
  • 319

1 Answers1

2

1) this code is always done in EDT, in other hands in one moment refreshed in the GUI

  • wrong way inside Runnable#Thread without use for invokeLater()

  • correct way inside Runnable#Thread wrapped into invokeLater()

2) you have two ways

3) in moment that you'll to able to manage whole stepped progresses inside Background task(s), then you can implements for Binding

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • is SwingWorker the only way to get fresh data on a jTable? Is that true? Is there other ways to refresh jTable insted of using unbind() and bind() ? Can FirePorpertyChange help me? – user1066163 Dec 06 '11 at 18:18
  • right SwingWorker (and Runneble#Thread too, but is easiest for workaround) can move task(s) to the background, and output fron method done() is on EDT, FirePorpertyChange is important in this processes, my examples http://stackoverflow.com/search?q=user%3A714968+swingworker here – mKorbel Dec 06 '11 at 18:46
  • here http://stackoverflow.com/questions/7036509/how-do-i-simulate-a-buffered-peripheral-device-with-swingworker/7049095#7049095 are four methods how to whatever with JTable contents – mKorbel Dec 06 '11 at 18:54
  • Thx for Your reply mKorbel. I don't know if can be useful for someone, but I solved the issue in this manner. Old list declaration was: List list = new ArrayList(); Now the same declaration is: ObservableList list = ObservableCollections.ObservableList(new ArrayList()); Now I don't need to do unbind() and bind() and also I don't need jTable.revalidate(); Now I have ALWAYS jTable with fresh data for everything changes made on the list. Thx to all. – user1066163 Dec 07 '11 at 13:15