import java.awt.*;
/* <APPLET CODE ="FontMetricsClass.class" WIDTH=300 HEIGHT=200> </APPLET> */
public class FontMetricsClass extends java.applet.Applet
{
public void paint(Graphics g)
{
String s="Hello Java";
Font f=new Font("Arial",Font.BOLD+Font.ITALIC,20);
g.setFont(f);
FontMetrics met=g.getFontMetrics(f);
int ascent=met.getAscent();
int height=met.getHeight();
int leading=met.getLeading();
int baseline=leading+ascent;
for(int i=0;i<10;i++)
{
g.drawString("Line"+String.valueOf(i),10,baseline);
baseline+=height;
}
}
}
No comments:
Post a Comment