import javax.swing.*;
import javax.swing.event.*;



public class ShowWeb1 implements HyperlinkListener {
    JEditorPane editor;
    public void hyperlinkUpdate(HyperlinkEvent ev) {
    if (ev.getEventType()==HyperlinkEvent.EventType.ACTIVATED) {
       try {
         editor.setPage(ev.getURL());
       }
       catch (Exception e) {} // what to do?
   }
  
  }

   public void go(String [] args) throws Exception {
      String url="http://www.yahoo.com";
      if (args.length>0) url=args[0];
      editor = new JEditorPane();
      editor.addHyperlinkListener(this);
      editor.setEditable(false);
      editor.setPage(url);
      JScrollPane pane = new JScrollPane(editor);
      JFrame f = new JFrame("HTML Demo");
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      f.getContentPane().add(pane);
      f.setSize(800,600);
      f.show();
    }

   public static void main(String [] args) throws Exception {
      new ShowWeb1().go(args);
    }
}
