import java.applet.*;
import java.util.*;
import java.net.*;
import javax.swing.*;
import javax.swing.event.*;public class Book extends JApplet 
   implements ListSelectionListener
{  public void init()
   {  int i = 1;
      String s;
      Vector v = new Vector();
      while ((s = getParameter("link_" + i)) != null)
      {  v.add(s);
         i++;
      }
      JList links = new JList(v);
      Container contentPane = getContentPane();
      contentPane.add(links);
      links.addListSelectionListener(this);
   }
   
   public void valueChanged(ListSelectionEvent evt)
   {  if (evt.getValueIsAdjusting()) return;
      JList source = (JList)evt.getSource();
      String arg = (String)source.getSelectedValue();
      try
      {  AppletContext context = getAppletContext();
         URL u = new URL(arg);
         context.showDocument(u, "right");
      } catch(Exception e)
      {  showStatus("Error " + e);
      }
   }
}基本上差不多,你改一改!

解决方案 »

  1.   

    left.html<SCRIPT LANGUAGE="JavaScript"><!--
        var _info = navigator.userAgent; var _ns = false;
        var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
    //--></SCRIPT>
    <COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
        var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0)));
    //--></SCRIPT></COMMENT><SCRIPT LANGUAGE="JavaScript"><!--
        if (_ie == true) document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = 290 HEIGHT = 300  codebase="http://java.sun.com/products/plugin/1.1.1/jinstall-111-win32.cab#Version=1,1,1,0"><NOEMBED><XMP>');
        else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.1" java_CODE = "Book.class" WIDTH = 290 HEIGHT = 300  link_1 = "http://java.sun.com" link_2 = "http://www.gamelan.com" link_3 = "http://www.zhongwen.com" link_4 = "http://www.horstmann.com" link_5 = "http://www.prenhall.com" link_6 = "http://www.usps.gov" link_7 = "http://www.netscape.com"  pluginspage="http://java.sun.com/products/plugin/1.1.1/plugin-install.html"><NOEMBED><XMP>');
    //--></SCRIPT>
    <APPLET CODE = "Book.class" WIDTH = 290 HEIGHT = 300 ></XMP>
    <PARAM NAME = CODE VALUE = "Book.class" ><PARAM NAME="type" VALUE="application/x-java-applet;version=1.1">
    <PARAM NAME = link_1 VALUE ="http://java.sun.com">
    <PARAM NAME = link_2 VALUE ="http://www.gamelan.com">
    <PARAM NAME = link_3 VALUE ="http://www.zhongwen.com">
    <PARAM NAME = link_4 VALUE ="http://www.horstmann.com">
    <PARAM NAME = link_5 VALUE ="http://www.prenhall.com">
    <PARAM NAME = link_6 VALUE ="http://www.usps.gov">
    <PARAM NAME = link_7 VALUE ="http://www.netscape.com"></APPLET></NOEMBED></EMBED></OBJECT>
    <!--
    <APPLET  CODE = "Book.class" WIDTH = 290 HEIGHT = 300 >
    <PARAM NAME = link_1 VALUE ="http://java.sun.com">
    <PARAM NAME = link_2 VALUE ="http://www.gamelan.com">
    <PARAM NAME = link_3 VALUE ="http://www.zhongwen.com">
    <PARAM NAME = link_4 VALUE ="http://www.horstmann.com">
    <PARAM NAME = link_5 VALUE ="http://www.prenhall.com">
    <PARAM NAME = link_6 VALUE ="http://www.usps.gov">
    <PARAM NAME = link_7 VALUE ="http://www.netscape.com">
    </APPLET>
    -->
    <!--"END_CONVERTED_APPLET"--></BODY>
    </HTML>
      

  2.   

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import java.net.*;
    import java.applet.AppletContext;public class MyApp extends Applet
    {
    public void init(){
       Button b = new Button("www.yeah.net");
       b.addActionListener(new ActionListener(){
           public void actionPerformed(ActionEvent e){
              try{
                 URL url = new URL("http://www.javasoft.com/index.html");
                 System.out.println("http://www.javasoft.com/index.html");
                 getAppletContext().showDocument(url);
              }
              catch(MalformedURLException murl){
                 System.out.println("bad url !");
              }   
           } 
        
       }); 
              
       add(b);
       
    }

    }