/** 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 fbm = getFontMetrics(fb);
       FontMetrics fim = getFontMetrics(fi);
       FontMetrics fbim = getFontMetrics(fbi);
       
       String s = "This is a plain font";
       String t = "This is a bold font";
       String u = "This is an italic font";
       String v = "This is a bold italic font";
       
  
       
       int xstart1 = (size().width - fm.stringWidth(s)) / 2;
       int xstart2 = (size().width - fbm.stringWidth(t)) / 2;
       int xstart3 = (size().width - fim.stringWidth(u)) / 2;
       int xstart4 = (size().width - fbim.stringWidth(v)) / 2;
       
       int fht = fm.getHeight();
       int fbht = fbm.getHeight();
       int fiht = fim.getHeight();
       int fbiht = fbim.getHeight();
       
      
       g.setColor(Color.blue);
       g.setFont(f);
       g.drawString(s,xstart1,25);
       
       g.setColor(Color.magenta);
       g.setFont(fb);
       g.drawString(t,xstart2,50);
       
       g.setColor(Color.orange);
       g.setFont(fi);
       g.drawString(u,xstart3,75);
       
       g.setColor(Color.green);
       g.setFont(fbi);
       g.drawString(v,xstart4,100);
       
       
       
      
       
       
      
       

      
       }
    }
