Friday, 14 June 2013
program in java - use various font with awt
import java.awt.*;
import java.awt.event.*;
class a12 extends Frame
{
public static void main(String args[])
{
a12 a=new a12();
a.setTitle("Set Font to 5 strings");
a.setSize(500,500);
a.setVisible(true);
a.addWindowListener(new myclass());
}
public void paint(Graphics g)
{
g.drawRect(250,250,250,300);
/*Font f=new Font("Arial",Font.BOLD,25);
g.setFont(f);*/
g.setColor(Color.red);
g.setFont(new Font("Arial",Font.BOLD,25));
g.drawString("The strig is ",300,300);
g.setColor(Color.blue);
g.setFont(new Font("Impact",Font.BOLD,25));
g.drawString("The strig is ",300,350);
g.setColor(Color.gray);
g.setFont(new Font("Comic Sans MS",Font.BOLD,25));
g.drawString("The strig is ",300,400);
g.setColor(Color.cyan);
g.setFont(new Font("Palatino Linotype",Font.BOLD,25));
g.drawString("The strig is ",300,450);
g.setColor(Color.pink);
g.setFont(new Font("MS Serif",Font.BOLD,25));
g.drawString("The strig is ",300,500);
}
}
class myclass implements WindowListener
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
public void windowClosed(WindowEvent we)
{
}
public void windowIconified(WindowEvent we)
{
}
public void windowDeiconified(WindowEvent we)
{
}
public void windowActivated(WindowEvent we)
{
}
public void windowDeactivated(WindowEvent we)
{
}
public void windowOpened(WindowEvent we)
{
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment