Java Reference
In-Depth Information
Think of software components as being similar to hardware components.
Suppose, for example, that you want to build a computer. You could start
by trying to build a computer chip (no small task) or you could go down to
your local electronics store and purchase a chip. While you're there, you
might as well purchase the other various hardware components that
make up a computer, such as a motherboard, video card, sound card,
keyboard, monitor, mouse, and so on. Note that you don't have to
understand how the components work to hook them together. You just
need to understand how to hook them together using your tools. I have
no idea how a video card works, but I do know how one plugs into a PC's
motherboard.
Similarly, you don't have to understand how a software component works
to use it, as long as you understand what the purpose is of the
component and how it is hooked to other components. For example, you
do not need to know how to program in Java to use JavaBeans. (Of
course, to write them, you do.) When hooking beans together, the builder
tool generates all the necessary code.
Simple Properties
A simple property of a JavaBean is an attribute of the bean that can be viewed
and can be changed by other beans. A simple property can be a read-only, a
write-only, or a read-write property, and the simple properties of a bean are
determined by the set and get methods in a bean's class, which have the fol-
lowing syntax:
public void set< Property >( data_type x)
public data_type get< Property >()
If both a set and get method appear that have the same property name and
data type, the bean will have a read-write property of the specified name. If
only a get method appears, the property is read-only; similarly, if only a set
method appears, the property is write-only.
For example, suppose that a bean has the following methods:
public void setTitle(String t)
public String getTitle()
Then, the bean has a read-write property named title, and the data type of
this property is a String. When the data type is a Boolean, an is method can be
Search WWH ::




Custom Search