Basic HTML version of Foils prepared March 26 1999

Foil 16 Using the new class

From Java Academy:Graphical User Interface NPAC Java Academy February--April 99 -- March 1999. by Nancy McCracken

Template for Applet to Draw a Canvas with Control Components
1 First the applet must create a new instance of the class. Note that the class name is used like a type (just like the built-in Java class names). Drawarea drawing = new Drawarea ( ); This executes the constructor, doing the initialization.
2 Now the applet can refer to variables in the class (e.g. x) using the dot notation with the instance, drawing: drawing.x = 10;
3 and use methods from the class: drawing.paint ( g );

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 Fri Mar 26 1999