org.jdesktop.swing.data
Class JavaBeanDataModel

java.lang.Object
  extended byorg.jdesktop.swing.data.AbstractDataModel
      extended byorg.jdesktop.swing.data.DefaultDataModel
          extended byorg.jdesktop.swing.data.JavaBeanDataModel
All Implemented Interfaces:
DataModel

public class JavaBeanDataModel
extends DefaultDataModel

A class that creates a collection of MetaData based BeanInfo PropertyDescriptors. To use this class:

  1. Construct the model using the Bean class you wish to model
  2. use setJavaBean to set the current object of this class.
  3. Updates made to the form will update the property values of the bean.

TODO: Using JavaBeans as a data source should be generalized and not constrained to FormModels.


Field Summary
 
Fields inherited from class org.jdesktop.swing.data.AbstractDataModel
validators
 
Constructor Summary
JavaBeanDataModel(Class beanClass)
           
JavaBeanDataModel(Class beanClass, Object bean)
          Constructs a JavaBeanDataModel by introspecting on the class and using the data from the object as the current bean
 
Method Summary
 Object getJavaBean()
          Get the JavaBean instance that this model uses.
 Object getValue(String fieldName)
           
 void setJavaBean(Object bean)
          Set the JavaBean instance that this model will use.
protected  void setValueImpl(String fieldName, Object value)
           
 
Methods inherited from class org.jdesktop.swing.data.DefaultDataModel
addField, addField, getFieldCount, getFieldNames, getMetaData, getRecordCount, getRecordIndex, removeField, setRecordIndex
 
Methods inherited from class org.jdesktop.swing.data.AbstractDataModel
addValidator, addValueChangeListener, fireValueChanged, getValidators, getValueChangeListeners, removeValidator, removeValueChangeListener, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaBeanDataModel

public JavaBeanDataModel(Class beanClass)
                  throws IntrospectionException

JavaBeanDataModel

public JavaBeanDataModel(Class beanClass,
                         Object bean)
                  throws IntrospectionException
Constructs a JavaBeanDataModel by introspecting on the class and using the data from the object as the current bean

Parameters:
beanClass - the class to use to introspect properties
bean - the object where the current values will be retrieved and stored.
Method Detail

setJavaBean

public void setJavaBean(Object bean)
Set the JavaBean instance that this model will use.


getJavaBean

public Object getJavaBean()
Get the JavaBean instance that this model uses.


getValue

public Object getValue(String fieldName)
Specified by:
getValue in interface DataModel
Overrides:
getValue in class DefaultDataModel

setValueImpl

protected void setValueImpl(String fieldName,
                            Object value)
Overrides:
setValueImpl in class DefaultDataModel


Copyright 2004 by Sun Microsystems, Inc. All Rights Reserved.