AWT Graphics Class

AWT Graphics class includes methods for drawing many different types of shapes. To draw a shape, we may call one of the methods available in the AWT Graphics class.




Drawing MethodDescription
clearRect()It erases a rectangular area of the canvas.
copyArea()It copies a rectangular area of the canvas to another area.
drawArc()It draws a hollow arc.
drawLine()It draws a straight line.
drawOval()It draws a hollow oval.
drawPolygon()It draws a hollow polygon.
drawRect()It draws a hollow rectangle.
drawRoundRect()It draws a hollow rectangle with rounded corners.
drawstring()It draws a text string.
fillArc()It draws a filled arc.
fillOval()It draws a filled oval.
fillPolygon()It draws a filled polygon.
fillRect()It draws a filled rectangle.
fillRoundRect()It draws a filled rectangle with rounded corners.
getColor()It retrieves the current drawing color.
getFont()It retrieves the currently used font.
getFontMetrics()It retrieves information about the current font.
setColor()It sets the drawing color.
setFont()It sets the font.

Recommended Posts:

Advanced Java
1. Java Applet
2. Applet Life Cycle in Java
3. Difference Between Applet and Application
4. Creating an Executable Applet in Java
5. Displaying Numerical values in Applet
6. An Applet Program to Add Two Numbers
7. Event Handling in Applet
8. AWT Event Classes
9. AWT Graphics Class
10. Draw a line and rectangle in Java Applet
11. Draw Circles and Ellipses in Java Applet
12. Draw a Polygon in Java Applet
13. AWT Hierarchy | AWT Package
14. Swing in Core Java