Listing of CapacityApplet.java ?version 2 / / <APPLET code="CapacityApplet.class" width=275 height=200></APPLET> // CapacityApplet - version 2 import java.applet.Applet; import java.awt.*; public class CapacityApplet extends Applet { // instance variables int capacity[] = new int[4]; // methods public void init() { capacity[0] = 55; capacity[1] = 34; capacity[2] = 80; capacity[3] = 101; } public void paint( Graphics g ) { // local variables for position of text int x = 10; int y = 10; // display class name in window g.drawString("Capacity Applet - version 2", x, y ); y = y + 25; // loop to display each element of 'capacity' int index; for( index = 0; index < capacity.length; index++) { g.drawString("capacity[" + index + "] = " + capacity[index],x,y); y = y + 20; } } } // class Back to top
 RITSEC - Global Campus Copyright © 1999 RITSEC- Middlesex University. All rights reserved. webmaster@globalcampus.com.eg
|