/********************************************************************
Class MessageBox
 --Help and About windows

Authors: Kristi Garner, Mary Garland    
CS406: Java and Internet Programming
*******************************************************************/
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class MessageBox extends Frame implements ActionListener {
	
	private Label message;
	private Button close;
	private String info;
	Font myfont = new Font ("Arial",Font.BOLD, 20);
	Font myfont2 = new Font ("Arial",Font.PLAIN, 12);
	public MessageBox(String title,
					  Image im, int width, int height) {
		
	
		
		setTitle(title);
		setLayout(new BorderLayout());
		setSize(width, height);
		setResizable(false);
		TextArea BoxInfo = new TextArea(this.WIDTH, this.HEIGHT- 50 );
		BoxInfo.setFont (myfont);
		//this.drawImage(im);
		add("Center",BoxInfo);
		//ruleshead = getImage(getCodeBase(), "ruleshead.jpg");
		//add(ruleshead, BorderLayout.NORTH );
		//message = new Label (messageString);
		//BoxInfo.append(message );
		if (title == "About Information"){
			
			BoxInfo.append("Java Scrabble\n");		
			BoxInfo.append("by Mary Garland and Kristi Garner\n");
			BoxInfo.append("CS 406\n");
			BoxInfo.append("Spring 1999\n");
			BoxInfo.append("Millersville University\n");
			BoxInfo.append("Millersville, Pennsylvania\n");
		}
		else if(title == "Game Information") {
			BoxInfo.append("Rules of the Game\n");
			BoxInfo.setFont (myfont2);
			BoxInfo.append("The first player combines two or more of his or her letters to form a word and places it on the board to read either across\n");
			BoxInfo.append(" or down with one letter on the center  square. Diagonal words are not permitted.\n");
            BoxInfo.append("Each player places their own tiles by individually clicking on one tile, then clicking a square to place the tile in that location.\n");
			
			BoxInfo.append("A player completes a turn by clicking on the Done button and then the opponent accepts it by clicking on the Accept button.\n");			   
			BoxInfo.append("At any time before the Done button is clicked, the player may remove all the tiles s/he placed on the board by clicking on \n");
			BoxInfo.append("the Undo button. The player may then start placing tiles again. After the Done button is clicked, the player can no longer \n");
			BoxInfo.append("make changes to tile placement.\n");
			BoxInfo.append("The score is then automatically calculated and the textboxes with the score information are automatically updated. The players\n ");			   
			BoxInfo.append("tiles are replenished to seven tiles again. The second player, and then each in turn, adds one or more letters to those already\n");
			BoxInfo.append("played to form new words. All letters played in a turn must be placed in one row across or down the board to form one complete\n ");
			BoxInfo.append("word. If, at the same time, they touch other letters in adjacent rows, they must form complete words, crossword fashion, with\n");
			BoxInfo.append("all such letters. \n");
			BoxInfo.append("New words may be formed by: \n");

            BoxInfo.append("          a.Adding one or more letters to a word or letters already on the board.\n"); 
            BoxInfo.append("          b.Placing a word at right angles to a word already on the board. The new word must use one of the letters already on the\n");
            BoxInfo.append("            board or must add a letter to it.\n");
            BoxInfo.append("          c.Placing a complete word parallel to a word already played so that adjacent letters also form complete words.\n");
                                    
            BoxInfo.append("No letter may be shifted after it has been played and the turn completed. \n");

            BoxInfo.append("The two blank tiles may be used as any letters. When playing a blank, the player must state which letter it represents.\n");
            BoxInfo.append("It remains that letter for the rest of the game. \n");

		}				   
		close = (new Button("Close"));
		close.addActionListener(this);
		add("South",close );
		addWindowListener(new CloseWindow());
	}
	public void actionPerformed(ActionEvent e){
		setVisible(false);
	}
	public void quitWindow(){
		this.dispose();
	}
}
	
