Sample: BeanDemo

Objectives

This sample illustrates how to build an application using visual composition.

Before you begin

Classes sunw.demo.molecule.Molecule and sunw.demo.juggler.Juggler must be loaded before editing or running this application.  You can do this by importing their jar files.

Description

This sample illustrates using features of visual composition for the following tasks:

Running the BeanDemo Sample

The BeanDemo sample includes a bean that demonstrates using beans inside beans.  It incorporates the Molecule Viewer and the Juggler applet from the Sun BDK inside a Frame.

To run the sample:

  1. Select the BeanDemo class from the Projects page.
  2. Select the Run button on the tool bar.
The view of the molecule bean can be rotated by pressing the left mouse button and moving the cursor. The type of molecule being viewed can be selected from the choice list.

The juggler animation can be started and stopped by pressing the appropriate button.

To build the BeanDemo Sample

There is only one bean in the beandemo package and it is called BeanDemo.  Follow the build instructions below.

Building the BeanDemo class

  1. Create the BeanDemo class as follows:
  2. The Visual Composition page of the class browser will be displayed, where you can build the user interface as follows:
  3. Add nonvisual beans:
  4. Save the bean and generate code:
  5. Make connections to set properties and invoke methods as follows (see Connection Syntax ):
Save the bean, and the sample is ready to run!