IBM Java AWT Samples

Objectives
The IBM AWT Samples are provided as examples of how to use the Java AWT classes in the Java class libraries.

Time Required
Running any one AWT Sample will take only a few minutes.  To thoroughly explore and experiment with changing the code, you may want to set aside 30 minutes for each sample with which you want to work.

Before You Begin
To add sample project to your workspace:

  1. Select Quick Start from the File menu.
  2. From the left-hand list, select Feature.
  3. From the right-hand list, select Add Feature.
  4. From the dialog that opens, select IBM Java Examples.  If IBM Java Examples does not appear in the list, it means that the project has previously been added to your workspace.

The IBM Java Examples project will be added to your workspace, and the source code will be compiled.  The project includes the Hanoi sample, the IBM Java AWT samples, and several Visual Composition Editor samples.

Description
The IBM Java AWT samples provide a large variety of programs that demonstrate how to use the Java AWT classes.  The applets demonstrate animation, text manipulation, GUI programming, resource file usage, and event handling.

Each AWT sample can be run on its own as an application.  Alternatively, you can run the launcher application and launch one or more of the samples from the launcher interface.

See List of AWT Samples.

Running the Samples
To run a particular AWT sample:

  1. In the Workbench or a browser, select the package com.ibm.ivj.examples.awttests.
  2. From the package's pop-up menu, select Run, Run main.
  3. From the list of executable classes in the package, select the sample you want to run.
  4. Click OK.

To launch samples from the launcher program:

  1. In the Workbench or a browser, select the package com.ibm.ivj.examples.awttestlauncher.
  2. From the package's pop-up menu, select Run, Run main.
  3. The AwtExampleLauncher list will be displayed.  Drag the window border so that all the examples are visible.
  4. Select one or more of the example programs by clicking on their names.  To deselect a name, click on it again.
  5. To run the selected programs, click the Execute button.

The samples programs have instructions on what to do with the interface.

If the programs cannot find resource files, set the class path by doing the following steps:

  1. In the Workbench, select Options in the Window menu.
  2. Select the Resources and Paths page.
  3. Click the Edit button next to the Workspace class path field.
  4. Click the Add Directory button.
  5. Select the project_resources/IBM Java Examples directory.  Click OK to add this directory to the workspace class path for finding resources.
  6. Click OK to set the class path.
  7. Click OK to exit the Options dialog.
  8. Start the sample application again.

To learn more about the AWT classes and how they work, experiment with the sample classes by changing the code or writing your own programs, using the samples as guides.   If you make changes and later want to restore the original samples, simply replace the edition in the workspace with the original edition in the repository.

List of AWT Samples

Sample Description
AwtBlueGreenGem Demonstrates animation, keyboard events, mouse-dragging, and use of resource files.
AwtBorderLayoutUseCase Demonstrates the border layout manager, menus, and buttons.
AwtButtonUseCase Demonstrates button actions.
AwtCardLayoutUseCase Demonstrates the card layout manager and button events.
AwtCheckboxUseCase Demonstrates the use of checkboxes.
AwtChoiceUseCase Demonstrates the use of drop-down lists.
AwtClock Demonstrates programming an analog clock.
AwtClipboardUseCase Demonstrates use of the clipboard.
AwtColorBrowser Demonstrates use of Color.
AwtColorQueryChangeExample Demonstrates changing colors of GUI components and mouse actions.
AwtCursorUseCase Demonstrates using and changing cursor styles.
AwtDelegationEventExample Demonstrates the event delegation model (all events are printed to the Console).
AwtDefaultColorText Demonstrates querying the default color of a component.
AwtDialogUseCase Demonstrates using dialogs.
AwtEventExample Demonstrates handling events (all events are printed to the Console).
AwtFileDialogUseCase Demonstrates using the file dialog.
AwtFlowLayoutUseCase Demonstrates the flow layout manager.
AwtFocusTraversalTest Demonstrates focus change events.
AwtGridLayoutUseCase Demonstrates the grid layout manager.
AwtInputEventTest Demonstrates processing key and mouse events.
AwtLabelUseCase Demonstrates the use of labels.
AwtLightweightExample Demonstrates the Lightweight API.
AwtLineTests Demonstrates line operations.
AwtListUseCase Demonstrates the use of lists.
AwtMenuUseCase Demonstrates the use of menus.
AwtPaintUpdateExample Demonstrates paint operations.
AwtPropertiesUseCase Demonstrates getting properties (such as system properties).
AwtRectangleTests Demonstrates rectangle operations.
AwtRollingOTI Demonstrates animation, mouse and key events, and using resource files.
AwtSynthesizeKeyEventTest Demonstrates synthesizing key events.
AwtSynthesizeMouseEventTest Demonstrates synthesizing mouse events.
AwtScrollbarUseCase Demonstrates using scrollbars.
AwtScrollPaneUseCase Demonstrates using scroll panes.
AwtShowImage Demonstrates working with images (scaling, using filters).
AwtSplitterPanelExample Demonstrates using split panes.
AwtTextAreaUseCase Demonstrates working with text areas.
AwtTextFieldUseCase Demonstrates working with text fields.