您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Apply Index

Apply Page # 2

Activity 2 — Zener.java listing

(1) Study the example program Zener.java and answer the questions in it.

(2) Compile and run the applet with the appletviewer

NOTE: For the applet to work you need to have the GIF image files in the same directory as the Java source file:

zennerWaves.gif
zennerSquare.gif
zennerCircle.gif
zennerStar.gif
zennerCross.gif

The screen should look similar to the following run:

image78.gif (2688 bytes)

(3) Make the applet change the displayed shape, i.e. make the screen look these different ways:

image79.gif (3054 bytes)image80.gif (2629 bytes)

image81.gif (2894 bytes)  image82.gif (2916 bytes)

Discussion of notice the reduced yPos of the square (from the default 50) and the increased xPos of the circle (from the defalt 50) — this shows the success of the invocation of the inherited methods through the sending of the setX() and setY() messages in ShapeApplet.java .

Discussion of Activity 2
Back to content

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg