Java-Font

Font

An object of type java.awt.Font represents a font. To select a new font, first create a Font object you must supply the font name, the style of the font, and size. The setFont( ) method is used to set the font. To set the background color of an applet’s window, use setBackground( ) method.

Program

0 (1)

Program Source

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Font;

public class Javaapp extends Applet {
   
    public void paint(Graphics g)
    {
        setBackground(Color.orange);
        Font f = new Font("Impact", Font.ITALIC, 22);        
        g.setFont(f);
        g.setColor(Color.red);
        g.drawString("ABCDEFGHIJ", 100, 100);
    } 
}

Leave a Comment