/**
 * @(#)LinkFollower.java 11/03/05
 * 
 * Copyright 2005 3GP01, KCL.  All unmodified code is copyright of its respective owner.
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * The GNU General Public Licence should be contained within licence.txt;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA  02110-1301, USA.
 */

import javax.swing.*;
import javax.swing.event.*;

/**
 * This class enables simple hyperlink following in the Help System.
 */

//http://www.cafeaulait.org/books/jnp2e/examples/08/::
public class LinkFollower implements HyperlinkListener 
{
	private JEditorPane pane;

	public LinkFollower(JEditorPane pane) 
	{
		this.pane = pane;
	}

	public void hyperlinkUpdate(HyperlinkEvent evt) 
	{
		if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) 
		{
			try 
			{
				pane.setPage(evt.getURL());
			} 
			catch (Exception e) 
			{
			}
		}
	}
}