Use BeanBox test container to customize example Beans
Customize Design Time Bean
Let us insert a Bean into the BeanBox to get familiar with how the BeanBox works in design time mode. Click the link below to insert and customize a Bean in design time mode. The JavaBeans API makes it possible to write component software in the Java programming language.
Components are self-contained, reusable software units that can be visually composed into composite components, applets, applications, and servlets using visual application builder tools. JavaBean components are known as Beans.
Customizing Java Bean at Design Time using BeanBox
Objective: Customize the BlueButton Bean at design time with the Bean Box
Launch the BeanBox by executing the run.bat file in the beanbox directory beneath the main Bdk directory. (Remember: the JDK's bin directory must be included in your system path in order for the BeanBox to work correctly.)
In the ToolBox window, click on the text BlueButton. Note that the mouse pointer has changed to a crosshair.
Move the crosshair over the BeanBox window.
Click in the BeanBox window to insert the bean.
The BlueButton Bean now appears in the BeanBox window. You can now customize the bean.
Click the blue box in the Properties window. The ColorEditor appears.
Click the arrow to the right of the word blue.
A drop-down menu appears.
Click on the orange; menu item. The BlueButton bean is now orange.
Close the ColorEditor window.
In the Properties window, click in the label field. Delete the word press.
In the label field, type Push me!.
The BeanBox should now contain an orange button with a Push me! label.
Javabeans Components
Components expose their features (for example, public methods and events) to builder tools for visual manipulation.
A Bean's features are exposed because feature names adhere to specific design patterns. A "JavaBeans-enabled" builder tool can then examine the Bean's patterns, discern its features, and expose those features for visual manipulation.
A builder tool maintains Beans in a palette or toolbox.
You can
select a Bean from the toolbox,
drop it into a form,
modify its appearance and behavior,
define its interaction with other Beans, and
compose it and other Beans into an applet, application, or new Bean.
All this can be done without writing a line of code.
Persistence
Generally, all components have state. The thermostat component has state that represents the comfort temperature.
If the thermostat were a software component of a computer-based heating control system, we would want the value of the comfort temperature to be stored on a non-volatile storage medium (such as the hard disk). In this manner, if we shut down the application and brought it back up again, the thermostat control would still be set to 73 degrees. The visual representation and position of the thermostat relative to other components in the application would be restored as well. Components must be able to participate in their container's persistence mechanism so that all components in the application can provide application-wide persistence in a uniform way. If every component were to implement its own method of persistence, it would be impossible for an application container to use components in a general way. This would not be an issue if reuse were not the goal. If we were building a monolithic temperature control system [HAL 9000] we might create an application-specific mechanism for storing state.
But we want to build the thermostat component so that it can be used again in another application, so we have to use a standard mechanism for persistence.
In the next lesson, the BlueButtonBean will be tested in runtime mode.