Got some old code you'd like to update? Have a look at how it's
done with the NervousText example program that's been distributed
with the JDKTM.
All AWT components in JDK 1.1 are Beans. This means they are already
set up to be used as reusable components in builder tools. However,
older JDK 1.0 programs and some JDK 1.1 demo programs are not built as
Beans. This lesson describes how to convert existing programs and
applets into Beans.
You'll start by taking the NervousText sample applet and turning
it into a Bean. You can look at this file in the JDK 1.1 distribution
tree under the directory demo/NervousText
.
There are several advantages to learning about Beans by converting
existing programs. First, you'll be able to concentrate on the parts
of the program or applet that are unique to Beans.
Second, by working on a familar example program that is somewhat
typical of other programs you may need to convert, you will see the
Beans features you need to learn first.
The concepts introduced in this lesson include:
- Reflection
- Event Handling
- Bean Customization
Start by taking a look at the existing JDK 1.1 code for the
NervousText.java.
As you may already know, this applet displays jittering text on
the screen, giving the impression that the text has had a little
too much coffee this morning. The JDK 1.1 version of NervousText
will be the starting point of reference from which subsequent
changes in this lesson will be made.
The next section, Making NervousText
into a Bean, contains the steps to make the conversion.