Basic HTML version of Foils prepared June 5 99

Foil 51 Using objects from Java packages

From Java Language in the Computer Science Curriculum ADMI Tutorial Duluth Minnesota -- June 3 99. by Geoffrey C. Fox


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.
Or you can more succintly use the import statement to open the context of the package java.awt:
import java.awt.*;
public class MyApplet extends java.applet.Applet
{ public void init ( )
{ Button b1 = new Button ( "start");
Button b2 = new Button ( "stop");
. . .
}
}
This calls the class constructor method Button to create the new instance and initialize the label .



© 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 Sat Jun 5 1999