The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.beans  [12 examples]

e1. The Quintessential Bean

This example bean has a single property called property. If the property were not a boolean, it would not have an isX() method. Also, if the property were read-only, it would not have a setX() method.
    import java.io.Serializable;
    
    public class BasicBean implements Serializable {
        boolean property;
        public BasicBean() {
        }
        public boolean getProperty() {
            return property;
        }
        public boolean isProperty() {
            return property;
        }
        public void setProperty(boolean newValue) {
            property = newValue;
        }
    }

 Related Examples
e2. Implementing a Bound Property
e3. Implementing a Constrained Property
e4. Instantiating a Bean
e5. Listing the Property Names of a Bean
e6. Getting and Setting a Property of a Bean

See also: Events    Serialization   


© 2002 Addison-Wesley.