Drawing & Painting Commands
After importing the Applet package and creating a new class extending the Applet class, you are ready to use some of the painting and drawing tools in Java. This is done by using the "paint" method which takes a Graphics object as a parameter. In the example below, the actual Graphics object parameter has been named 'g'. This is customary buy you can name it anything you want as long as you're consistent when creating graphics with it.
Inside the paint method, the Graphics object's methods are called to actually do the drawing and painting. For example:
This code would produce the following applet when run in Eclipse:
Essentially, you are drawing a 50 x 50 pixel rectangle with its upper left-hand boundary at coordinates (10, 10).