2016-03-04 33 views
0

我有一個結合如果引用改變了,我必須再次綁定嗎?

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被分配了一個新的對象,我必須再次綁定嗎?

回答

0

我做錯了。

我在MessageCatcher類中沒有PropertyChangeSupport。

當我添加PropertyChangeSupport時,實現了PropertyChangeListener方法,添加了firePropertyChange方法,更改了方法的創建,只是將其字段重置爲新值都奏效了。

相關問題