Basic HTML version of Foils prepared July 6 99

Foil 35 Using objects from Java packages

From Use of Java Language in Computational Science DoD Modernization Users Group Conference Monterey -- June 7 99. by Nancy McCracken, Geoffrey C. Fox


1 Suppose that you want to use two Buttons in an applet. The Button class is in the package java.awt. java.awt.Button b1 = new java.awt.Button( "label" ); All objects created this way are represented internally as references.
2 Or you can more succintly use the import statement to open the context of the package java.awt:
3 import java.awt.*;
4 public class MyApplet extends java.applet.Applet
5 { public void init ( )
6 { Button b1 = new Button ( "start");
7 Button b2 = new Button ( "stop");
8 . . . b1.setLabel ( "pause");
9 }
10 }
11 This calls the class constructor method Button to create the new instance and initialize the label .

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Jul 6 1999