
//HelpFrame.java
//Created: March 1997, by Dave Kreiner
//
//This utility provides a simple help frame utility.
//
// To compile into byte code:
//    javac HelpFrame.java
// Does not have it's own main method...used to support Vig2.class
//
import java.awt.*;
import java.io.*;
public class HelpFrame extends Frame
{
	String helpname;
	File hfile;
	
	TextArea helpscreen;
	Button dismiss;

	public HelpFrame(String s) 
	{
		super("Help Utility");
		helpname = new String(s+".hel");
	}
	
	public void startup()
	{
		setSize(300,200);
		helpscreen = new TextArea(15,40);
		helpscreen.setFont(new Font("courier",Font.PLAIN,14));
		dismiss = new Button("Dismiss");
		add("Center",helpscreen);
		add("South",dismiss);
		setVisible(true);
		loadfile();
	}

	public boolean handleEvent(Event e)
	{
		if (e.id == Event.WINDOW_DESTROY || e.target == dismiss)
		{
			setVisible(false);
			dispose();
			
			return true;
		}
		return super.handleEvent(e);
		
	}


	public void loadfile()
	{
		try
		{
			hfile = new File(helpname);
			BufferedReader in = 
					new BufferedReader(new InputStreamReader(new FileInputStream(hfile)));
			String l = new String(in.readLine());
			while (l != null)
			{
				helpscreen.append(l + "\n");	
				l = new String(in.readLine());
			}
		} catch (IOException b) {System.err.println("Caught: "+b);}
	}
}















