    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.IOException;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
   import javax.swing.JScrollPane;
   import javax.swing.JTextField;
   import javax.swing.event.HyperlinkEvent;   
   import javax.swing.event.HyperlinkListener;
import java.io.*;
import java.util.*;

   public class web extends JFrame implements ActionListener,HyperlinkListener
   {
      private JTextField enterField; // JTextField to enter site name
      private JEditorPane contentsArea; // to display website

      // set up GUI
      public web()
      {
         super( "Simple Web Browser" );

         // create enterField and register its listener
         enterField = new JTextField( "Enter file URL here" );
         enterField.addActionListener(this);
         add( enterField, BorderLayout.NORTH );

         contentsArea = new JEditorPane(); // create contentsArea 
         contentsArea.setEditable( false );                       
         contentsArea.addHyperlinkListener(this);                                 
         add( new JScrollPane( contentsArea ), BorderLayout.CENTER );
         setSize( 400, 300 ); // set size of window
         setVisible( true ); // show window
      } // end web constructor
      
      public void actionPerformed( ActionEvent event )
               {
                  getThePage( event.getActionCommand() );
               } // end method actionPerformed
      
      public void hyperlinkUpdate( HyperlinkEvent event )
               {                                                  
                  if ( event.getEventType() ==                    
                       HyperlinkEvent.EventType.ACTIVATED )       
                     getThePage( event.getURL().toString() );     
               } // end method hyperlinkUpdate              
      
      // load document
      private void getThePage( String location )
      {
         try // load document and display location
         {  StringTokenizer token=new StringTokenizer(location,":");
            int n=token.countTokens();
            String s1[]=new String[n];
            int i=0;
            while(token.hasMoreTokens())
           {s1[i]=(String)token.nextToken();i++;}
            if(!s1[0].equals("http")) location="http://"+location;
            contentsArea.setPage( location ); // set the page
            enterField.setText( location ); // set the text
         } // end try
         catch ( IOException ioException )
         {
            JOptionPane.showMessageDialog( this,
               "Error retrieving specified URL", "Bad URL",
               JOptionPane.ERROR_MESSAGE );
         } // end catch
      } // end method getThePage
      public static void main( String args[] )
      {
         web application = new web();
         application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      } // end main
   } // end class web
