/** 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);
       
       int xstartf = (size().width - fm.stringWidth("JAVA IS GROOVY"))/2; 
       int xstartfb = (size().width - fbm.stringWidth("JAVA IS GROOVY"))/2; 
       int xstartfi = (size().width - fim.stringWidth("JAVA IS GROOVY"))/2; 
       int xstartfbi = (size().width - fbim.stringWidth("JAVA IS GROOVY"))/2; 
       
       g.setFont(f);
       g.setColor(Color.blue);
       g.drawString("JAVA IS GROOVY", xstartf, 25);
       
       g.setFont(fb);
       g.setColor(Color.green);
       g.drawString("JAVA IS GROOVY", xstartfb, 50);
       
       g.setFont(fi);
       g.setColor(Color.orange);
       g.drawString("JAVA IS GROOVY", xstartfi, 75);
       
       g.setFont(fbi);
       g.setColor(Color.red);
       g.drawString("JAVA IS GROOVY", xstartfbi, 100);
       }
    }