Start Search Contents Index Links About
FontViewer.java
/*
 * Author: Havard Rast Blok
 * E-mail:  
 * Web   : www.rememberjava.com
 */

import java.awt.*;
import javax.swing.*;

/**
 * An application to view a specified font.
 */
public class FontViewer extends JFrame
{
  
  private Font f;
  
  public FontViewer(String name, int style, int size)
  {
    super("FontViewer");
    
    //make font
    f = new Fontname, style, size);
    
    //show frame
    setSize300200 );
    show();
  }
  
  public void paint(Graphics g)
  {
    //show font
    g.setFont(f);
    g.drawString("Hello World!"20150);
  }
  
  public static void main(String[] args)
  {
    int style=0;
    
    // check and parse the command line arguments
    ifargs.length < )
    {
      System.out.println("Usage: java FontViewer <fontname> <size> [bold] [italic]");
      System.exit(1);
    }
    
    for(int i=2; i<args.length; i++)
    {
      ifargs[i].compareToIgnoreCase("bold"== )
      {
        style += Font.BOLD;
      }
      else ifargs[i].compareToIgnoreCase("italic"== )
      {
        style += Font.ITALIC;
      }      
    }
    
    new FontViewerargs[0], style, Integer.parseInt(args[1]));
   
    
  }
  
}


site: Håvard Rast Blok
mail:
updated: 27 July 2007