Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 
Training Index

Introduction to the JavaBeans API, Magercise 7
The StickFigure Bean with a Customizer Dialog

by John Zukowski, MageLang Institute

[Help | API Docs | Short Course | Magercises]

This Magercise focuses on the design and implementation of a customization dialog, as well as its specification within the bean-info class.

Magercise 7 Prerequisites

Skeleton Code

Tasks

  1. The first step is to create a working directory somewhere on your filesystem, hereafter referred to as workingdir.

  2. Next, create the directory stickfigure (all lowercase characters) directly under workingdir.

  3. Next, (1) save all the skeleton files, except the *.java files and GIF file, within workingdir and (2) save the *.java skeleton files and GIF file within stickfigure, that is, within workingdir/stickfigure.

  4. The next, and primary, task is to design and implement a customizer dialog for the body-part properties, the "sunburned" property, and the "mood" property. The skeleton code appears in StickFigureCustomizer.java. This class must extend a container class, for example, Panel and implement the Customizer interface.

    The customization dialog should provide controls for each of the body-part properties, as well as for the "sunburned" property, for example, independent (nonexclusive) Checkbox instances organized in a nested panel. Also, it should provide a radio button-style control for the "mood" property.

  5. The next task is to augment the bean-info class, StickFigureBeanInfo. Add a getBeanDescriptor() method that returns a BeanDescriptor instance and associates StickFigureCustomizer.class with StickFigure.class.

  6. Compile all JavaTM source files, *.java, from workingdir by including the stickfigure directory in the path specification.

  7. Build StickFigure.jar from workingdir by executing the file MakeStickFigureJar.bat (Windows) or MakeStickFigureJar.sh (UNIX).

  8. Next, load the StickFigure Bean into the BeanBox (or a comparable tool) using "LoadJar..." from the BeanBox "File" menu.

  9. Lastly, test the customizer dialog for StickFigure Bean. Activate the dialog by choosing "Customize..." from the BeanBox's "Edit" menu--the customizer dialog is modal (a blocking dialog). Other Bean-aware tools may, for example, provide a "Customize" command button in the property sheet, or elsewhere.

    Verify that selecting different values from the toggle buttons changes the image so that it displays various combinations of body parts. Verify that the radio buttons correctly manipulate the mood, and that changes to mood from the customizer are immediately reflected in the property sheet.

Where help exists, the task numbers above are linked to the step-by-step help page.

Solution Source

Demonstration

After loading the StickFigure Bean, it should appear in the palette, from where it can be selected and instantiated on the worksheet:

Notice the restricted number of properties displayed in the property sheet, as well as the custom "mood" property editor.

Magercise 8
Short Course
About This Short Course

Copyright © 1998-1999 MageLang Institute. All Rights Reserved.


[ This page was updated: 27-Oct-99 ]

Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-99 Sun Microsystems, Inc.
All Rights Reserved. Legal Terms. Privacy Policy.