import java.awt.*; import java.applet.*; public class SetFontExample extends Applet { public void paint(Graphics g) { // set font to Arial, bold, size 16 Font font = new Font("Arial", Font.BOLD, 16); g.setFont(font); g.drawString("Hello, World!", 50, 50); } }In this example, we are creating an instance of Font class for Arial, with bold style and size 16. Then, we set this font to graphics object using setFont() method. Finally, we draw a string "Hello, World!" using drawString() method. Package Library: The setFont() method is part of java.awt.Graphics class which is part of the java.awt package.