home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java by Example
/
jbecd.bin
/
JBE-CD
/
NTUsers
/
JBECODE.ZIP
/
JavaByExample
/
chap17
/
FontApplet.java
< prev
next >
Wrap
Text File
|
1996-02-21
|
946b
|
37 lines
import java.awt.*;
import java.applet.*;
public class FontApplet extends Applet
{
public void paint(Graphics g)
{
Font font = getFont();
String name = font.getName();
String family = font.getFamily();
int n = font.getStyle();
String style;
if (n == 0)
style = "Plain";
else if (n == 1)
style = "Bold";
else if (n == 2)
style = "Italic";
else
style = "Bold Italic";
n = font.getSize();
String size = String.valueOf(n);
String info = font.toString();
String s = "Name: " + name;
g.drawString(s, 50, 50);
s = "Family: " + family;
g.drawString(s, 50, 65);
s = "Style: " + style;
g.drawString(s, 50, 80);
s = "Size: " + size;
g.drawString(s, 50, 95);
g.drawString(info, 20, 125);
}
}