|
Hello Applet Page
|
tarix | 07.11.2018 | ölçüsü | 43,82 Kb. | | #78522 |
|
Lab 6 - Applets & Applications
Student Handout
1. Lab Objectives
Following the lab you should be able to:
-
Distinguish between an application and an applet.
-
Create an applet with multiple methods.
-
Execute applets using three methods (i.e., applet viewer, browser, and as an application).
-
Explain when to use applets to solve a problem.
-
List the advantages and disadvantages of applets.
2. Prior to the laboratory
-
Review the laboratory handout.
-
Read Wu, Chapter 0, Page 12.
-
Read Chapters 36-38, http://chortle.ccsu.edu/CS151/cs151java.html
-
Read the tutorial, “Writing Applets”, http://java.sun.com/docs/books/tutorial/applet/index.html
3. Topics
4. Activities/Exercises
-
Running a simple Java application.
-
Running an applet from a browser (IE).
-
Changing a method in an applet program.
-
Creating a more complex design.
-
Exploring some utility applets
Activity 1: Running a simple Java application
-
Download the program HelloApplication.java from the class website.
-
Study the sample code to determine what it does.
-
Compile and run the HelloApplication program.
-
Download the program HelloApplet.java from the class website.
-
Study the sample code and note its difference from the HelloApplication.java program.
-
Compile HelloApplet.java.
-
Run the applet by choosing “Run as -> Java Applet” from the Run menu in the document window.
-
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.
-
Compile and run the applet in the applet viewer again.
-
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!!!
Dostları ilə paylaş: |
|
|