如果引用更改,我是否必须重新绑定?
Do I have to bind again if reference changed?
我有绑定
org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${catched}");
org.jdesktop.swingbinding.JListBinding jListBinding = org.jdesktop.swingbinding.SwingBindings.createJListBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, messageCatcher1, eLProperty, jList1);
jListBinding.setDetailBinding(org.jdesktop.beansbinding.ELProperty.create("${message}"));
jListBinding.setSourceNullValue("no value");
bindingGroup.addBinding(jListBinding);
但是在代码执行期间,messageCatcher1 被分配了一个新对象。在我的代码中:
setMessageCatcher1(
new MessageCatcher(
new Catcher<Message>()
{
Pattern pattern = Pattern.compile(getRegexText());
@Override
public boolean catchMessage(Message m)
{
Matcher matcher = pattern.matcher(m.getMessage());
return matcher.find();
}
},
md.findBySQL(getSQLText())
)
);
如果 messageCatcher1 被分配了一个新对象,我是否必须重新绑定?
我做错了。
我在 MessageCatcher 中没有 PropertyChangeSupport class。
当我添加 PropertyChangeSupport、实现 PropertyChangeListener 方法、添加 firePropertyChange 方法、将方法的创建更改为仅将其字段重置为新值时一切正常。
我有绑定
org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${catched}");
org.jdesktop.swingbinding.JListBinding jListBinding = org.jdesktop.swingbinding.SwingBindings.createJListBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, messageCatcher1, eLProperty, jList1);
jListBinding.setDetailBinding(org.jdesktop.beansbinding.ELProperty.create("${message}"));
jListBinding.setSourceNullValue("no value");
bindingGroup.addBinding(jListBinding);
但是在代码执行期间,messageCatcher1 被分配了一个新对象。在我的代码中:
setMessageCatcher1(
new MessageCatcher(
new Catcher<Message>()
{
Pattern pattern = Pattern.compile(getRegexText());
@Override
public boolean catchMessage(Message m)
{
Matcher matcher = pattern.matcher(m.getMessage());
return matcher.find();
}
},
md.findBySQL(getSQLText())
)
);
如果 messageCatcher1 被分配了一个新对象,我是否必须重新绑定?
我做错了。
我在 MessageCatcher 中没有 PropertyChangeSupport class。
当我添加 PropertyChangeSupport、实现 PropertyChangeListener 方法、添加 firePropertyChange 方法、将方法的创建更改为仅将其字段重置为新值时一切正常。