Java Reference
In-Depth Information
<void property=”station”>
<float>100.3</float>
</void>
<void property=”volume”>
<int>10</int>
</void>
</object>
</java>
Similarly, you could use the readObject() method of the XMLDecoder class to read in
the Radio object into an application. Typically, you do not need to write the code to encode
an XML object because the bean builder tools do this for you.
For example, in the Bean Builder program, if you hook together a collection of Java-
Beans, you can save the design in an XML file by selecting File, Save on the main menu of
the Bean Builder. You could then extract the information in a Java program using the
XMLDecoder class.
BeanInfo Class
Every bean can have a BeanInfo class that denotes the properties, methods,
and events of a bean. The BeanInfo class is useful for many situations, includ-
ing the following:
If you have an existing class that you want to make into a bean, but the
class did not follow the naming conventions of the JavaBeans specifica-
tion, you can use the BeanInfo class to denote the set and get methods
of properties and the add and remove methods of events.
■■
You might have some properties that are simple, some that are bound,
and others that are constrained. The BeanInfo class lets you denote this.
■■
You can use the BeanInfo class to denote default properties, those that
will most often be used by other beans.
■■
Similarly, you can denote a default event that most beans will likely
use. Smart builder tools will use these default values to make them-
selves more user-friendly.
■■
You can create a customizer for a bean, which allows you to write your
own GUI for changing and viewing the properties of a bean in a builder
tool.
■■
You can specify icons for a bean for use in various situations by the
bean builder tools.
■■
Search WWH ::




Custom Search