import java.awt.*; public class Example { public static void main(String[] args) { Frame frame = new Frame("Example"); frame.setSize(400, 400); frame.setVisible(true); Graphics g = frame.getGraphics(); g.drawString("Hello World!", 100, 100); g.dispose(); } }In this example, a frame is created with the title "Example" and size of 400 x 400 pixels. The graphics object is obtained from the frame and used to display the message "Hello World!" at coordinates (100, 100). Finally, the dispose() method is called to release any system resources used by the graphics object. The java.awt package library provides classes for creating and manipulating 2D graphics and images.