Usage of Font and Color class

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


public class ColorFont extends Applet
{
public void init()
{
Color color1=new Color(230,220,0);
setBackground(color1);
}
public void paint(Graphics g)
{
String str="";
String FontList[];
GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
FontList = ge.getAvailableFontFamilyNames();
g.drawString("Font Available ARE :", 5, 30);
for(int i=0;i {
str+=FontList[i]+",";
g.drawString(str, 5, 50);
}



Color color2=new Color(235,50,50);
g.setColor(color2);
g.drawString("Hey Look..!!", 5, 180);
Font currentFont=new Font("TimesRoman",Font.PLAIN,20);
g.setFont(currentFont);
g.drawString("This is Example",5,220);
currentFont=new Font("Times Roman", Font.ITALIC, 40);
g.setFont(currentFont);
g.drawString("YOU must have understood....", 5, 260);
}
}



No comments: