HELP! * GREY=local LOCAL HTML version of Foils prepared July 10 1996

Foil 141 Graphics is Event-Driven: paint method

From Basic Lectures on Java Language Applets Graphics Networking Trip to China and Icase Tutorial -- July 12-28 and June 10-13 96. by Geoffrey C. Fox * See also color IMAGE

In every applet or windows application, the windowing system creates an Image with a Graphics object to keep track of the state of the window.
In order to draw or write text to the window, you must override the paint method:
  • void paint(Graphics g)
In this method you put everything you want to draw in the window. The Graphics object g has things like a current color and current font, and there are methods for you to change these as well as draw.
The window system can be interrupted for various reasons - the user resized it or some other window was put on top of it and then removed - and it does not save a copy of the pixels. Instead it calls a method called update, which blanks the screen and then calls paint(g). So even if you only draw one window, paint can be called many times.



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 Feb 18 1997