Bean Internals  «Prev 

Customizing JavaBeans at Design time

Bean properties are modifiable at design time through visual property editors or through straight coding.
By altering property values, an application developer can customize both the appearance and behavior of Beans.
This customization is carried out either visually or programmatically, depending on the development tools being used.
Bean customization is covered later in this course.

Design-time versus Run-time

It is certainly possible that you would want to design a Bean that behaved differently at design-time than it does at run-time. Maybe the Bean does an enormous amount of processing, or it has some other feature that just doesn't lend itself well to a design-time environment. A development tool can call the
setDesignTime() 
method on the java.beans.Beans class to indicate whether or not the system is running in design mode. In turn, your Bean can call the isDesignTime() method on the same class to find out if it is running in design mode. This call could be made at the time the Bean is instantiated and stored in a variable. This way the Bean can always check the state of this variable before performing a function that is dependent upon whether it is running in design mode.
The problem is that some development tools may be able to switch between design-time mode and run-time mode on the fly, without having to create different instances of the Bean. The current JavaBeans architecture does not provide a way for Beans to listen for changes in the design mode. Therefore, even though you can get this information at any time by calling isDesignTime(), you have no way of knowing if and when you should be calling it. Depending on the development tool you are using, this could be a real problem. Hopefully, future versions of the JDK will allow Beans to become event listeners for changes to the design mode status.