FileDocCategorySizeDatePackage
Browser1.javaAPI DocExample1841Mon Oct 16 19:44:08 BST 2000None

Browser1

public class Browser1 extends JFrame implements HyperlinkListener

Fields Summary
private JEditorPane
html
private URL
url
Constructors Summary
public Browser1(String site)

	setSize( 350, 450 );
		setTitle( "Basic Browser" );
		addWindowListener( new WindowAdapter() {
			public void windowClosing( WindowEvent e )
			{	System.exit( 0 );
			}
		});

		try
		{	url = new URL( site );
		}
		catch( MalformedURLException e )
		{	System.out.println( "Invalid URL specified" );
			System.exit( 0 );
		}
		try
		{	html = new JEditorPane( url );
		}
		catch( IOException e )
		{	System.out.println( "Can't load url: " + url );
			System.exit( 0 );
		}
		
		getContentPane().add( html );
		html.setEditable( false ); // to allow links to be activated
		html.addHyperlinkListener( this );

		setVisible( true );
	
Methods Summary
public voidhyperlinkUpdate(javax.swing.event.HyperlinkEvent e)

	if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
		{	try
			{  html.setPage( e.getURL() );
			}
			catch( IOException ioe )
			{	System.out.println( "Can't load url: " + url );
				System.exit( 0 );
			}
		}
	
public static voidmain(java.lang.String[] args)

	new Browser1( args[0] );