Hi HelpIndex Bean Example Code

Last modified: 26 February 1998.

Page Contents Example 1 
See also Bean Information  HiDemo example 

For a full working example using Hi HelpIndex and Hi brow please see the HiDemo example.


Example 1

Note that this example may need to be changed to support your chosen browser bean.

In particular, if using the Sun Hot Java bean, the following changes need to be made.

import java.awt.*;
import COM.phdcc.hi.*;

////////////////////////////////////////////////////////////////////////////////

public class Frame1 extends Frame
{
	HelpIndex hi = new HelpIndex();
	Brow browser = new Brow();

	String displayTarget = "_self";

	public Frame1()
	{
		IndexParam ip = new IndexParam("file:///C:/siteindex.hi");
		hi.setIndex(0,ip);
		hi.addPropertyChangeListener(new Frame1_hi_propertyChangeAdaptor(this));

		browser.addPropertyChangeListener(new Frame1_browser_propertyChangeAdaptor(this));

		add("East",hi);
		add("Center",browser)
	}
	void setDisplayTarget(String target)
	{
		displayTarget = target;
	}
	void setDisplayPage(String page)
	{
		browser.setDisplayTarget(displayTarget);
		browser.setDisplayPage(page);
	}
	void setDisplayedPage(String page)
	{
		hi.setDisplayPage(page);
	}
	... other Frame stuff ...
}

////////////////////////////////////////////////////////////////////////////

class Frame1_hi_propertyChangeAdaptor
	implements java.beans.PropertyChangeListener
{
	private Frame1 adaptee;
	Frame1_hi_propertyChangeAdaptor(Frame1 adaptee)
	{
		this.adaptee = adaptee;
	}
	public void propertyChange(PropertyChangeEvent e)
	{
		String propertyName = e.getPropertyName();
		if( propertyName=="displayTarget")
			adaptee.setDisplayTarget((String)e.getNewValue());
		if( propertyName=="displayPage")
			adaptee.setDisplayPage((String)e.getNewValue());
	}
}

////////////////////////////////////////////////////////////////////////////

class Frame1_browser_propertyChangeAdaptor
	implements java.beans.PropertyChangeListener
{
	private Frame1 adaptee;
	Frame1_browser_propertyChangeAdaptor(Frame1 adaptee)
	{
		this.adaptee = adaptee;
	}
	public void propertyChange(PropertyChangeEvent e)
	{
		String propertyName = e.getPropertyName();
		if( propertyName=="displayPage")
			adaptee.setDisplayedPage((String)e.getNewValue());
	}
}

HelpIndex    PHD