JTable中绑定不允许 [英] JTable binding not permitted
问题描述
我有一个java.util.List的绑定到一个JTable,如果我想用刷新表
I've got a java.util.List bind to a JTable, if I want to refresh the table using
- bindingGroup.unbind();
- bindingGroup.bind();
我得到这个异常:
异常螺纹线程8java.lang.UnsupportedOperationException:不能调用此方法的管理结合
Exception in thread "Thread-8" java.lang.UnsupportedOperationException: Can not call this method on a managed binding
相对于上面的第二行。
下面更具体的code:
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是我写的JProgressBar的激活一个简单的方法,这里没有什么是参与结合。
fireProgressBar is a simple method that I wrote for jProgressBar activation, nothing here is involved in binding.
在bindingGroup.bind()调用抛出上述异常。
the bindingGroup.bind() call throws the exception above.
我也试图与SwingUtilities.invokeLater,而不是新的Thread(....)开始();
但我得到了同样的问题。
I tried also with SwingUtilities.invokeLater instead of new Thread(....).start(); but I get the same issue.
感谢。
推荐答案
1)本code一直在做EDT,在其他的手在GUI刷新一个时刻
1) this code is always done in EDT, in other hands in one moment refreshed in the GUI
-
在
的Runnable#主题
错误的方式,而不使用了的invokeLater()
wrong way inside
Runnable#Thread
without use forinvokeLater()
的Runnable#主题
裹成的invokeLater()
2)你有两种方式。
里面同样的方式的Runnable#主题
并输出到GUI必须被包裹成的invokeLater()
same way inside Runnable#Thread
and output to the GUI must be wrapped into invokeLater()
3)在那一刻,你会要能够管理整个阶梯后台任务(S)内的进步,那么你就可以实现了绑定
3) in moment that you'll to able to manage whole stepped progresses inside Background task(s), then you can implements for Binding
这篇关于JTable中绑定不允许的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!