Write a Java Applet program to demonstrate Font class methods
import java.applet.Applet;
import java.awt.Font;
import java.awt.Graphics;
public class FontDemoApplet extends Applet {
public void paint(Graphics g) {
Font f = g.getFont();
String fontName = f.getFontName(); // Getting Font name
String fontFamily = f.getFamily(); // Getting Font family
int fontStyle = f.getStyle(); // Getting Font style
int fontSize = f.getSize(); // Getting Font size
String fontStl = "Font Style = ", fontS;
fontName = "Font Name = " + fontName;
fontFamily = "Font Family = " + fontFamily;
fontS = "Font Size = " + fontSize;
if( fontStyle == Font.PLAIN )
fontStl += "Plain";
if( fontStyle == Font.BOLD )
fontStl += "Bold";
if( fontStyle == Font.ITALIC )
fontStl += "Italic";
g.drawString(fontName, 50, 50);
g.drawString(fontFamily, 50, 80);
g.drawString(fontS, 50, 110);
g.drawString(fontStl, 50, 140);
}
}
/* <applet code="FontDemoApplet.class" width=200 height=200>
</applet>
*/