Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Create simple applet and print text in various fonts

  1. /* Using Fonts */
  2. /* Syntax
  3.  Font(String F_Name, int F_Style, int F_ps) ps -> Size in Points
  4.    To Set new Font Use Function
  5.  Void setFont(Font f)
  6. */
  7. /* Color Cosntants { black, blue, cyan, darkGray, gray, green, ligntGray,
  8.        magenta, orange, pink, red, white, yellow}
  9. */
  10. import java.applet.Applet;
  11. import java.awt.Graphics;
  12. import java.awt.Font;
  13. import java.awt.Color;
  14. /*
  15.  <applet code = "Applet05" width = 300 height = 300>
  16.  </applet>
  17. */
  18. public class Applet05 extends Applet
  19. {
  20.  public void paint(Graphics g)
  21.  {
  22.    g.setColor(Color.blue);
  23.     Font f = new Font("Impact",Font.PLAIN, 30);
  24.    g.setFont(f);
  25.    g.drawString("Hello World...",50,50);
  26.    g.setFont(new Font("Serif",Font.BOLD, 20));
  27.    g.drawString("Hello World...",75,100);
  28.  }
  29. }
Your rating: None Average: 5 (1 vote)
Share this

Post new comment

14 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.