/** Assignment:  Modify this file (previously ManyFonts
 ** on p. 202 of the text) by changing it to center each 
 ** of the different fonts horizontally, and to give each        
 ** a different color. Make sure to check out SimpleApplet3 
 ** first, which shows how to do these things.  Also, edit 
 ** MyApplet6.html in the  project directory, to run the
 ** MyApplet6.class file you create, and to look nice.   **/                                                               

import java.awt.*;

public class MyApplet6 extends java.applet.Applet 
  {public void paint(Graphics g) 
  
      {Font f = new Font("TimesRoman", Font.PLAIN, 18);
       Font fb = new Font("TimesRoman", Font.BOLD, 18);
       Font fi = new Font("TimesRoman", Font.ITALIC, 18);
       Font fbi = new Font("TimesRoman", Font.BOLD + Font.ITALIC, 18);
       
       FontMetrics fm = getFontMetrics(f);
        FontMetrics fm2 = getFontMetrics(fb);
       FontMetrics fm3 = getFontMetrics(fi);
       FontMetrics fm4 = getFontMetrics(fbi);
       int xstartf = 
	  (size().width - fm.stringWidth("This is a plain font"))/2;
      
       int xstartfb = 
	  (size().width - fm2.stringWidth("This is a plain font"))/2;
	
	int xstartfi = 
	  (size().width - fm3.stringWidth("This is a italic font"))/2; 
	
	int xstartfbi = 
	  (size().width - fm4.stringWidth("This is a bold italic font"))/2; 
	      
       g.setFont(f);
       g.setColor(Color.magenta);
       g.drawString("This is a plain font",  xstartf, 25);
       
       g.setFont(fb);
       g.setColor(Color.blue);
       g.drawString("This is a bold font",  xstartfb, 50);
       
        g.setFont(fi);
       g.setColor(Color.red);
       g.drawString("This is a italic font",  xstartfi, 75);
       
        g.setFont(fbi);
       g.setColor(Color.green);
       g.drawString("This is a bold italic font",  xstartfbi, 100);
       
       
       }
    }




