Developing Java Beans // the decrement button protected

Developing Java Beans them, while the other monitors those changes and updates its own Value property in response. Figure 4.5 shows an example. Figure 4.5. An applet using a constrained property If you continue to press the increment button, the labels will eventually have values of 20. If you try to increment again, the Constrainer object vetoes the change. The result is that the Value properties of both labels remain at 20. The same is true if you decrement the Value properties to 10. If you continue decrementing, the Constrainer object again vetoes the change and the Value properties remain at 10. Chapter 5. Persistence Most components maintain information that defines their appearance and behavior. This information is known as the state of the object. Some of this information is represented by the object’s properties. For instance, the font or color properties of a visual component are usually considered to be part of that object’s state. The Thermometer class that we’ve been discussing in previous chapters has a MinimumTemperature property that is part of its state. There may also be internal data used by an object that is not exposed as properties, but plays a part in defining the behavior of the object nevertheless. An applet or application may use one or more components, and these components will be configured to exhibit specific behavior. When the application is loaded, these components should automatically exhibit the prescribed behavior. This means that the state information of all of the components, as well as the application or applet itself, must be saved on a persistent storage medium so that it can be used to recreate the overall application state at run-time. Figure 5.1 shows that some portion of an application will be saved to, and subsequently restored from, persistent storage. An important aspect of application state is the definition of the components themselves: the persistent state of an application includes a description of the components being used, as well as their collective state. Figure 5.1. Saving and restoring components The JavaBeans architecture uses the Java object serialization mechanisms for persistence. These mechanisms are designed to make it very easy for simple Beans to implement persistence, while at the same time providing the flexibility needed by more complex Beans. We’ll see shortly that under page 70
Note: If you are looking for good and high quality web space to host and run your java application check Vision java hosting services

Comments are closed.