Help: The HTML/Applet Interface


Help is available for each task, or you can go straight to the solution source code.

Task 1

Create a new project by clicking on the "create new project" icon that looks like a little folder (the 7th icon from the left under the VisualAge for Java menu bar):
Type "The HTML Applet Interface" into the text field to the right of the radio button that says "Create a new project named:". Push the "Finish" button in the lower right corner of the dialog box. VisualAge will return you to the workbench after it has completed creating your package. You should see it listed with the other projects.
No help for this task.

Task 2

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.


No help for this task.

Task 3

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:
/**
 * paint() draws the text on the drawing area.
 */
public void paint(Graphics g) {
  g.setFont(font);
  g.setColor( Color.black );
  g.drawString("My title:"+getParameter("title"), 5, 50);
}
The browser will look something like this:

Using the popup menu in the bottom code pane (right mouse click), select "Save"--VisualAge will save and compile your new changes.


No help for this task.

Task 4

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:
<param name="title" value="President">
The dialog box should look like:

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).

<applet code="AppletParam" width=250 height=100>
<param name=package value="Default package for AppletParam">
<param name=title value="President">
</applet>

Finally, click on the "Run" button to test your applet. It should look like:


No help for this task.

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.