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
Print Button
 

Create and open a dialog box that waits for the user to hit the "OK" button before it disappears and the applet finishes. Have the applet add the label "Back from dialog..." to its display when the OK dialog has returned. Hide and dispose of the dialog box right before adding the label.

Skeleton Code

Tasks


  1. Create an applet with an init() method that makes a dummy Frame (because dialogs can only be "children" of frames) and then creates an OKDialog and shows the dialog. (OKDialog is defined in the next task.)

  2. Create OKDialog as a subclass of BlockingDialog (provided for you). It should add the label "Hit the button..." followed by an "OK" button. Use a FlowLayout object for geometry management and resize it to 100 x 100.

  3. In the applet's init() method:

    1. Call waitForResponse() (a blocking method) on the dialog right after showing it
    2. When the dialog (that is, waitForResponse()) returns, add the label "Back from dialog..." to the applet
    3. Dispose of the dialog

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

Solution Source

Demonstration

This exercise only runs within browsers that support the Java Runtime Environment 1.1 and appletviewer. If you are using an appropriate browser, try this exercise. The output should look similar to the following:

OKDIALOG.GIF

A dialog box should appear outside of the browser. If this does not occur, your browser does not handle dialog boxes properly.

Next Exercise

Exercises

Short Course

Copyright 1996-2000 jGuru.com. All Rights Reserved.


Print Button
[ This page was updated: 21-Sep-2000 ]
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary | Feedback | 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-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.