![]() |
The HTML/Applet Interface
This Magercise walks you through the creation of a simple Applet that accessing a parameter specified in the HTML that launches the applet. Work LocationPerform all work for this magercise in VisualAge project MageLang Magercises, package magercises.appletparameters. If this project does not appear in your Workspace add it from the repository (if it exists there) or create a new project using this name. Tasks
Perform the following tasks:
![]() Under the the "Window" menu of the workbench, choose item "Quick Start", which brings up a dialog box. Indicate that you would like to create an applet
![]() and click "OK". Type in "AppletParam" for the name of the applet and "The HTML Applet Interface" for the Project. Indicate that you would like to write the source code for the applet by clicking the appropriate radio button:
![]() and click "Finish" (do not click "Next" in this case). A dialog box will appear telling you that the default package for SimpleGUI does not exist. Answer that it should continue (that is, it should create the default package). A code browser will appear for you to edit your new applet.
Click on the "Hierarchy" tab of the code browser and select the
paint method in the "Methods" pane. The prewritten method
will be displayed in the bottom code pane. Modify it so that the
paint method looks like:
![]() Using the popup menu in the bottom code pane (right mouse click), select "Save"--VisualAge will save and compile your new changes.
Test your applet by clicking on the "running person" icon under the browser
menu bar. A dialog box will appear that allows you to set the parameters
used to invoke your applet. Modify the width,height to be 250,100 and
create a user-defined parameter in the "Parameters" pane called "title"
with a value of whatever your title is. For example:
![]() Click on the "Save" button to have VisualAge remember your settings for the next time you try to run this applet. After clicking the "Save" button you should get a notice that parameters have been saved in the repository.
VisualAge will be testing your applet as if an HTML web page had
the following embedded applet tag (assuming the .class
files were in the same directory).
Finally, click on the "Run" button to test your applet. It should look like:
![]()
|
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |