You are here: Home / Topics / Program to change Font using setFont() method in Java

Program to change Font using setFont() method in Java

Filed under: Java on 2023-10-16 07:07:16

//  Program to change Font using setFont() method.

import java.awt.*;
import java.applet.*;

/*
<applet code="DrawStringFontTest1a" width="200" height="100" >
</applet>
*/

public class  DrawStringFontTest1a  extends Applet  
{
Font f;

public void init() 
{
 setBackground( Color.yellow );
 f = new Font("Serif", Font.PLAIN, 35);
 setFont( f );
}

public void paint(Graphics g) 
{  
 g.drawString("Nils", 50, 70);
}
}


About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.