This simple Hello World! applet contains the following beans:
All the finished applet does at run time is split the text value of the JLabel bean into two substrings and copy each substring to an entry field.
Suppose the composite is saved after the beans have been dropped and edited for initial content. VisualAge generates field declarations and accessor methods as follows:
VisualAge also generates the following applet methods:
The first connection, connPtoP1, links the text property of MyHello to the this property of MyString. When you save the composite, VisualAge generates these additional methods:
Connections from the actionPerformed event of SplitButton to the text property of each TextField bean (connEtoM1 and connEtoM2) reset the text displayed in each entry field. By default, no event data is passed to the target of the connection, so each connection requires input for the new value of text. Parameter connections (connPfromM1 and connPfromM2) pass in these values: the value property of each push button connection is connected to the substring(int, int) method of MyString. The exact character indexes are provided as connection properties of connPfromM1 and connPfromM2.
Now when you save the composite, VisualAge generates these additional methods:
What is generated to handle the events that trigger the connections depends upon how you have the code generation option set. Suppose we had chosen Use one inner class for all events. In this case, the following is generated:
Suppose you then separate all text into a resource bundle:
In addition, the get methods are regenerated to retrieve the appropriate resources instead of using hardcoded text. With the use of a property file, the call for setting MyHello to "Hello, World!" looks something like this:
ivjMyHello.setText(resmyhello.getString("rHelloString"));resmyhello is the resource field generated by VisualAge.
Generated code
Generated BeanInfo descriptor code (an advanced topic)
Code generated from visually composed beans
How generated code coexists with user-written code
Internationalization in VisualAge
Exporting to the file system
Visual bean basics
Connecting beans
Separating strings for translation
Example of generated feature code
Beans for visual composition