Example of simple applet using
object of graphics class
You will have seen many applets that use
objects of the Graphics class. For example, a Graphics object is the argument
automatically passed to the applet when the system invokes the paint() method.
Consider the output of this applet:
The applet producing this output is as follows:
import
java.applet.Applet;
import java.awt.*;
public class DrawString1 extends Applet
{
public void paint( Graphics g )
{
g.drawString(
"text drawn with Graphics method 'drawString()'",
20, 20 );
}
} // class
Here a messagedrawString(...)is passed to the
Graphics object g— resulting in the invocation of the drawString()method
of the class Graphics.
Back
to top

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights
reserved.
webmaster@globalcampus.com.eg
|