Basic HTML version of Foils prepared March 26 1999

Foil 14 Canvas

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


Suppose that we want to use the drawing methods on a subarea of the applet. To do that, we introduce a Canvas, instead of a Panel.
Like an applet, you can have a paint (Graphics g) method for a canvas, in which you can call methods such as g.setColor( ) and g.drawRect ( ... ), and also the repaint( ) and update(Graphics g) methods are built in as well for canvases.
Since we want to define our own paint method for the canvas, we should define a separate class that extends a Canvas.



© 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