|
|
|||||
Evan Summers's BlogBound Gooey BeansPosted by evanx on February 05, 2007 at 03:07 AM | Comments (0)
In the Gooey Beans Info prequel, we explicitly declare properties. Now we allow a bean info instance to be bound to a specific bean, in order to support bound properties ie. firing PropertyChangeEvent's.
In our bean, we instantiate a bound bean info class with PropertyChangeSupport as follows.
public class BakedBean { public final BakedBeanInfo info = new BakedBeanInfo(this); private BigInteger barcode; private String label; private Integer bakingTemparature; private BigDecimal medianLength; ... public BakedBean() { } ... public void setBarcode(BigInteger barcode) { this.barcode = barcode; info.barcode.firePropertyChanged(barcode); } } where we use property "literals" from our bean info to firePropertyChanged(). We can add PropertyChangeListener's as follows.
public class BakedBeanDemo implements PropertyChangeListener, Runnable { BakedBean bean = new BakedBean(); ... public BakedBeanDemo() { ... bean.info.getPropertyChangeSupport().addPropertyChangeListener(this); } ... }
Bookmark blog post: CommentsComments are listed in date ascending order (oldest first) | Post Comment | |||||
|
|