Ques : What is Graphics Objects ?

, , No Comments

In Java all drawing takes place via a Graphics object. This is an instance of the class 

java.awt.Graphics.

Initially the Graphics object you use will be passed as an argument to an applet’s
paint() method. The drawing can be done Applet Panels, Frames, Buttons, Canvases
etc.

Each Graphics object has its own coordinate system, and methods for drawing strings,
lines, rectangles, circles, polygons etc. Drawing in Java starts with particular Graphics
object. You get access to the Graphics object through the paint(Graphics g) method of
your applet.

Each draw method call will look like
g.drawString("Hello World", 0, 50);

Where g is the particular Graphics object with which you’re drawing.
For convenience sake in this unit the variable g will always refer to a pre-existing
object of the Graphics class. It is not a rule you are free to use some other name for
the particular Graphics context, such as myGraphics or applet-Graphics or anything
else.

0 टिप्पणियाँ:

Post a Comment