Back Forward CDK Home Reference Samples Resources
ShowText

 Building the ShowText Component

The ShowText example illustrates the construction of a very basic Applet / Bean. As a re-usable component, it can be imported directly into visual application development environments like SUN's BeanBox or Netscape's Visual JavaScript.

The sample illustrates how to use naming conventions (to avoid namespace collision, thus improving re-usability and modularity), and also shows how to automatically generate documentation (in a manner similar to the JSBDoc tool) for Java components.

The component consists of one Java source file which is compiled and packaged into a JAR:


The JAR file is constructed using a batch file, which references a manifest file (ShowText.mf) which notes which file(s) in the JAR are JavaBeans:
Manifest-Version: 1.0

Name: netscape/samples/showtext/ShowText.class
Java-Bean: True

The JAR is build using a batch file / shell script (depending on your platform):

This script also generated the JavaDoc reference page (the images used by JavaDoc have not been included in this example). The CustomProperty sample illustrates how to extend ShowText to include a BeanInfo that allows the documentation to be opened at design time in tools that support this feature:

 Wiring the ShowText Sample

Open Visual JavaScript (PR3 or later), create a new project and add a new page using the "Blank Page Template".

After bringing up the Palette window using the Palette icon on the toolbar, click on a blank area of the palette using the right mouse button to bring up the context-menu. Select the "New" option to create a new Palette page (called "Unnamed1" or something similar). Switch to this new palette page by clicking on the tab.

Right click anywhere within the new blank palette page and select the Install JAR File option. Using the "Browse" button, select this newly created JAR, then select "OK" to add the JAR to the palette.

Drag the newly created Show Text item into the body of the page. A gray box appears, indicating an applet has been added to the page.

Select the "Form Elements" tab on the palette. Choose the "Text" icon and drag it to the body. A new form is created with a text area.

Select the connection point (the tiny square in the upper right corner of the text field), dragging and dropping the connection onto the ShowText applet on the page.

After you drag the text field's connection point onto the applet, the Connection Builder will appear. Press "Apply" then "Close" to create a connection.
Press the preview button on the Visual JavaScript toolbar. In a moment, your browser will load the newly created page. Typing text in the text area, then pressing the "Tab" key, will cause the applet to display the text from the textfield.

Congratulations! You have just built and run a Visual JavaScript Crossware Application!

A sample page showing the result is also included.


( return to the top of the page )