Hello Applet Page



Yüklə 43,82 Kb.
tarix07.11.2018
ölçüsü43,82 Kb.
#78522

RAIK 183H

Fall 2010



Lab 6 - Applets & Applications

Student Handout
1. Lab Objectives
Following the lab you should be able to:

  1. Distinguish between an application and an applet.

  2. Create an applet with multiple methods.

  3. Execute applets using three methods (i.e., applet viewer, browser, and as an application).

  4. Explain when to use applets to solve a problem.

  5. List the advantages and disadvantages of applets.


2. Prior to the laboratory


  1. Review the laboratory handout.

  2. Read Wu, Chapter 0, Page 12.

  3. Read Chapters 36-38, http://chortle.ccsu.edu/CS151/cs151java.html

  4. Read the tutorial, “Writing Applets”, http://java.sun.com/docs/books/tutorial/applet/index.html


3. Topics

Topic

Importing classes and packages (review)

The Applet Class

Differences between an applet and a Java program

Applet execution


4. Activities/Exercises

  1. Running a simple Java application.

  2. Running an applet from a browser (IE).

  3. Changing a method in an applet program.

  4. Creating a more complex design.

  5. Exploring some utility applets


Activity 1: Running a simple Java application

  1. Download the program HelloApplication.java from the class website.

  2. Study the sample code to determine what it does.

  3. Compile and run the HelloApplication program.

  4. Download the program HelloApplet.java from the class website.

  5. Study the sample code and note its difference from the HelloApplication.java program.

  6. Compile HelloApplet.java.

  7. Run the applet by choosing “Run as -> Java Applet” from the Run menu in the document window.

  8. Complete Question 1 on your worksheet for Activity 1.

Go to the following line in HelloApplet.java:

g.drawString("Hello World Applet!", 5, 20);


  • Change the last two arguments from 5, 20 to 200, 200.

  1. Compile and run the applet in the applet viewer again.

  2. Complete Question2 on your worksheet for Activity 1.

Activity 2: Running an applet from a browser

  • Create a new file from the Eclipse File menu (File…New -> Untitled Text File)

  • Type the following text into the new document you just created:





Hello Applet Page





!!!REPLACE THIS LINE WITH THE APPLET TAG!!!
Yüklə 43,82 Kb.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©www.genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə