AWT Classes in Java

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 Method


Description

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.

AWT Hierarchy:

The Abstract Window Toolkit (AWT) package in Java enables the programming to create GUI-based applications. It contains several classes that help to implement everyday window-based tasks—such as windows, adding a scroll bar, buttons, list items, text boxes, etc.

All the classes are contained in the java.awt package. These classes are hierarchically arranged inside the AWT package. AWT provides support for both standard and applet windows.