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

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)
next.gif
 (2959 bytes)

 
 
Extend Index
Extend Page # 9

Listing of ReverseArrayApplet.java ?version 1

// <APPLET code="ReverseArrayApplet.class" width=275 height=200></APPLET>
// ReverseArrayApplet - version 1
import java.applet.Applet;
import java.awt.*;
public class ReverseArrayApplet extends Applet
  {
  // instance variables
  char forward[] = {'h', 'e', 'l', 'l', 'o'};

  // methods
  public void init()
    {
    // nothing needed here for version 1 !
    }
public void paint( Graphics g )
    {
    // local variables for position of text
    int x = 10;
    int y = 10;
    // display class name in window
    g.drawString("Reverse Array Applet - version 1", x, y );
    y = y + 20;
    // Display "char array 'forward' contains:" in window
    g.drawString("char array 'forward' contains:", x, y );
    y = y + 20;
    // use Graphics method 'drawChars' to display char array
    g.drawChars( forward, 0, forward.length, x + 10, y );
    }
  } // class 

Back to top
basicline.gif (169 bytes)

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