/**
   @author H Fearn
*/

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;

public class FirstApp extends JApplet
{
   public void init()
   {

      Container contentPane = getContentPane();
/* set color for the main pane  */
      contentPane.setBackground(Color.red);
      contentPane.setLayout(new BorderLayout());

      JLabel label = new JLabel(getParameter("greeting"),
                                 SwingConstants.CENTER);

/*  add a bit of color to the label inside the panel */
      label.setForeground(Color.white);

      label.setFont(new Font("Comic Sans Script", Font.ITALIC, 36));
      contentPane.add(label, BorderLayout.CENTER);

      JPanel panel = new JPanel();
/*  add a bit of color to the panel at bottom */
      panel.setBackground(Color.yellow);

      JButton hfButton = new JButton("Heidi Fearn");
/*  add a bit of color to the Button at bottom */
      hfButton.setBackground(Color.blue);
      hfButton.setForeground(Color.white);

      hfButton.addActionListener(makeURLActionListener(
         "http://chaos.fullerton.edu/~heidi/heidi.html"));
      panel.add(hfButton);

      contentPane.add(panel, BorderLayout.SOUTH);
   }

   private ActionListener makeURLActionListener(final String u)
   {
      return new
         ActionListener()
         {
            public void actionPerformed(ActionEvent event)
            {
               try
               {
                  getAppletContext().showDocument(new URL(u));
               }
               catch(MalformedURLException e) 
               { 
                  e.printStackTrace(); 
               }
            }
         };
   }
}

