// Source Code for AdminHelpBox.class //
// Client Code for Desktop Calendar    //

// Code based on using Server #18     //
// Written by Khalid Mufti - Group 31 //

import java.awt.*;
import java.awt.event.*;

// This class handles the dialog which is used to display help information.  //
// Creates a dialog with a text area and an ok button.  Requires a           //
// parent frame, the Dialog Title, the Help string to display, whether to be //
// modal or not and the width and height of the window.                      //  
public class AdminHelpBox extends Dialog implements ActionListener
{
   private Button ok;
   private TextArea helptext;

   // The constructor for the class.  Requires a parent frame, the Dialog   //
   // Title, the Help string to display, whether to be modal or not and the // 
   // width and height of the window.                                       //  
   public AdminHelpBox (Frame parent, String title, String messageString,
                        boolean freeze, int width, int height)
   { 
      // Call Dialog class constructor //
      super (parent, title, freeze);

      // Set window size and type//
      setSize(width, height+1);
      setResizable (false);

      // Allocate memory for all new items in Dialog, and add action listeners //
      helptext = new TextArea (messageString, width, height,TextArea.SCROLLBARS_VERTICAL_ONLY);
      helptext.setEditable(false);
      add (helptext, BorderLayout.CENTER);
      ok = new Button ("OK");
      ok.addActionListener (this);
      add (ok, BorderLayout.SOUTH);

      // Add a listener for closing the window prematurely //
      addWindowListener (new CloseWindow());
   } 

   // This function handles any action events from the user //
   public void actionPerformed (ActionEvent e)
   {
      // If user pressed the ok button //
      if ((e.getSource())==ok) 
         dispose();
   }
}

