书上的一个例子
import javax.swing.text.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.awt.*;
import javax.swing.event.*;public class useSimpleWebBrowser 
{
public static void main(String[] args) 
{      
     // get the first URL
     String initialPage = "http://www.sohu.com";
     if (args.length > 0) initialPage = args[0];       
    
     // set up the editor pane
     JEditorPane jep = new JEditorPane();
     jep.setEditable(false);   
     jep.addHyperlinkListener(new LinkFollower(jep));
    
    try 
    {
       jep.setPage(initialPage);      
     }
     catch (IOException e) 
     {
       System.err.println("Usage: java SimpleWebBrowser url"); 
       System.err.println(e);
      System.exit(-1);
     }
      
     // set up the window
     JScrollPane scrollPane = new JScrollPane(jep);     
     JFrame f = new JFrame("Simple Web Browser");
     f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     f.getContentPane().add(scrollPane);
     f.setSize(512, 342);
     f.show();
   }
}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) 
       { } 
     }    
   }
}

解决方案 »

  1.   

    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    // Java extension packages
    import javax.swing.*;
    import javax.swing.event.*;public class ReadServerFile extends JFrame {
      private JTextField enterField;
      private JEditorPane contentsArea;  // set up GUI
      public ReadServerFile()
      {
         super( "Simple Web Browser" );     Container container = getContentPane();     // create enterField and register its listener
         enterField = new JTextField( "Enter file URL here" );     enterField.addActionListener(        new ActionListener() {           // get document specified by user
               public void actionPerformed( ActionEvent event )
               {
                  getThePage( event.getActionCommand() );
               }        }  // end anonymous inner class     ); // end call to addActionListener     container.add( enterField, BorderLayout.NORTH );     // create contentsArea and register HyperlinkEvent listener
         contentsArea = new JEditorPane();
         contentsArea.setEditable( false );     contentsArea.addHyperlinkListener(        new HyperlinkListener() {           // if user clicked hyperlink, go to specified page
               public void hyperlinkUpdate( HyperlinkEvent event )
               {
                  if ( event.getEventType() ==
                       HyperlinkEvent.EventType.ACTIVATED )
                     getThePage( event.getURL().toString() );
               }        }  // end anonymous inner class     ); // end call to addHyperlinkListener     container.add( new JScrollPane( contentsArea ),
            BorderLayout.CENTER );     setSize( 400, 300 );
         setVisible( true );
      }  // load document; change mouse cursor to indicate status
      private void getThePage( String location )
      {
         // change mouse cursor to WAIT_CURSOR
         setCursor( Cursor.getPredefinedCursor(
            Cursor.WAIT_CURSOR ) );     // load document into contentsArea and display location in
         // enterField
         try {
            contentsArea.setPage( location );
            enterField.setText( location );
         }     // process problems loading document
         catch ( IOException ioException ) {
            JOptionPane.showMessageDialog( this,
               "Error retrieving specified URL",
               "Bad URL", JOptionPane.ERROR_MESSAGE );
         }     setCursor( Cursor.getPredefinedCursor(
            Cursor.DEFAULT_CURSOR ) );
      }  // begin application execution
      public static void main( String args[] )
      {
         ReadServerFile application = new ReadServerFile();     application.setDefaultCloseOperation( 
            JFrame.EXIT_ON_CLOSE );
      }}  // end class ReadServerFile
      

  2.   

    看这个
    http://java-fan.vicp.net:10000/cgi-bin/topic.cgi?forum=23&topic=195&show=0
      

  3.   

    gtfcccq(蓝天)你的代码,在解析javascript脚本时不行啊,把那些脚本代码显示出来了啊!
    mymoto(忽忽) 你的程序好象不能运行啊,输入网址后没有用啊