JavaApplet嵌入html,打开html时为什么会弹出一个applet窗口。
本应该直接在html里显示的,打开html时竟然弹出了一个小的applet执行框。
html的代码
<html>
<head>
<title>ImageJA Applet</title>
</head>
<body bgcolor=gray>
<h1>ImageJ embedded in a website</h1>
<applet codebase="." code="ij.ImageJApplet.class" width=750 height=550></applet>
</body>
</html>
在ij目录下有对应的class文件。

解决方案 »

  1.   

    你不会有JFrame之类的吧, Applet本身是一个Panel, 装了Frame就会将Frame弹出来.
      

  2.   

    这个问题还没遇到过。。弹出式APPlet执行框??
    LZ,你将那个ImageJApplet代码发过来看下。。
      

  3.   

    这是ImageJApplet 类:public class ImageJApplet extends Applet { /** Starts ImageJ if it's not already running. */
        public void init() {
         ImageJ ij = IJ.getInstance();
          if (ij==null || (ij!=null && !ij.isShowing()))
    new ImageJ(this);
    for (int i=1; i<=9; i++) {
    String url = getParameter("url"+i);
    if (url==null) break;
    ImagePlus imp = new ImagePlus(url);
    if (imp!=null) imp.show();
    }
        }
        
        public void destroy() {
         ImageJ ij = IJ.getInstance();
         if (ij!=null) ij.quit();
        }}
      

  4.   

    这是ImageJApplet 里调用的ImageJ类:
    package ij;import java.applet.Applet;
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import java.awt.image.*;
    import ij.gui.*;
    import ij.process.*;
    import ij.io.*;
    import ij.plugin.*;
    import ij.plugin.filter.*;
    import ij.plugin.frame.*;
    import ij.text.*;
    import ij.macro.Interpreter;
    import ij.io.Opener;
    import ij.util.*;
    public class ImageJ extends Frame implements ActionListener, 
    MouseListener, KeyListener, WindowListener, ItemListener, Runnable { /** Plugins should call IJ.getVersion() to get the version string. */
    public static final String VERSION = "1.42p";
    public static Color backgroundColor = new Color(220,220,220); //224,226,235
    /** SansSerif, 12-point, plain font. */
    public static final Font SansSerif12 = new Font("SansSerif", Font.PLAIN, 12);
    /** Address of socket where Image accepts commands */
    public static final int DEFAULT_PORT = 57294;
    public static final int STANDALONE=0, EMBEDDED=1; private static final String IJ_X="ij.x",IJ_Y="ij.y";
    private static int port = DEFAULT_PORT;
    private static String[] arguments;

    private Toolbar toolbar;
    private Panel statusBar;
    private ProgressBar progressBar;
    private Label statusLine;
    private boolean firstTime = true;
    private java.applet.Applet applet; // null if not running as an applet
    private Vector classes = new Vector();
    private boolean exitWhenQuitting;
    private boolean quitting;
    private long keyPressedTime, actionPerformedTime;
    private String lastKeyCommand;
    private boolean embedded;
    private boolean windowClosed;

    boolean hotkey;

    /** Creates a new ImageJ frame that runs as an application. */
    public ImageJ() {
    this(null, EMBEDDED);
    }

    /** Creates a new ImageJ frame that runs as an applet. */
    public ImageJ(java.applet.Applet applet) {
    this(applet, 1);
    } public ImageJ(java.applet.Applet applet, int mode) {
    super("ImageJ");
    embedded = applet==null && mode==EMBEDDED;
    this.applet = applet;
    String err1 = Prefs.load(this, applet);
    if (IJ.isLinux()) {
    backgroundColor = new Color(240,240,240);
    setBackground(backgroundColor);
    }
    Menus m = new Menus(this, applet);
    String err2 = m.addMenuBar();
    m.installPopupMenu(this);
    setLayout(new GridLayout(2, 1));

    // Tool bar
    toolbar = new Toolbar();
    toolbar.addKeyListener(this);
    add(toolbar); // Status bar
    statusBar = new Panel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setForeground(Color.black);
    statusBar.setBackground(backgroundColor);
    statusLine = new Label();
    statusLine.setFont(SansSerif12);
    statusLine.addKeyListener(this);
    statusLine.addMouseListener(this);
    statusBar.add("Center", statusLine);
    progressBar = new ProgressBar(120, 20);
    progressBar.addKeyListener(this);
    progressBar.addMouseListener(this);
    statusBar.add("East", progressBar);
    statusBar.setSize(toolbar.getPreferredSize());
    add(statusBar); IJ.init(this, applet);
      addKeyListener(this);
      addWindowListener(this);
    setFocusTraversalKeysEnabled(false);
     
    Point loc = getPreferredLocation();
    Dimension tbSize = toolbar.getPreferredSize();
    int ijWidth = tbSize.width+10;
    int ijHeight = 100;
    setCursor(Cursor.getDefaultCursor()); // work-around for JDK 1.1.8 bug
    if (IJ.isWindows()) try {setIcon();} catch(Exception e) {}
    setBounds(loc.x, loc.y, ijWidth, ijHeight); // needed for pack to work
    setLocation(loc.x, loc.y);
    pack();
    setResizable(!(IJ.isMacintosh() || IJ.isWindows())); // make resizable on Linux
    if (err1!=null)
    IJ.error(err1);
    if (err2!=null) {
    IJ.error(err2);
    IJ.runPlugIn("ij.plugin.ClassChecker", "");
    }
    if (IJ.isMacintosh()&&applet==null) { 
    Object qh = null; 
    qh = IJ.runPlugIn("MacAdapter", ""); 
    if (qh==null) 
    IJ.runPlugIn("QuitHandler", ""); 

    if (applet==null)
    IJ.runPlugIn("ij.plugin.DragAndDrop", "");
    m.installStartupMacroSet();
    String str = m.getMacroCount()==1?" macro)":" macros)";
    String java = "Java "+System.getProperty("java.version")+(IJ.is64Bit()?" [64-bit]":" [32-bit]");
    IJ.showStatus("ImageJ "+VERSION + "/"+java+" ("+ m.getPluginCount() + " commands, " + m.getMacroCount() + str);
    if (applet==null && !embedded && Prefs.runSocketListener)
    new SocketListener();
    configureProxy();
    show();
      }
        
    void configureProxy() {
    String server = Prefs.get("proxy.server", null);
    if (server==null||server.equals("")) return;
    int port = (int)Prefs.get("proxy.port", 0);
    if (port==0) return;
    String user = Prefs.get("proxy.user", null);
    Properties props = System.getProperties();
    props.put("proxySet", "true");
    props.put("http.proxyHost", server);
    props.put("http.proxyPort", ""+port);
    if (user!=null)
    props.put("http.proxyUser", user);
    //IJ.log(server+"  "+port+"  "+user);
    }

        .....
      

  5.   

    没法上传图片。我的意思就是:本来希望applet的内容嵌在html中显示,但现在打开html,那个applet的小应用程序自己弹出了一个窗口出来,没有嵌入在html中打开。。
    谢谢各位的支持,非常着急,已经拖了两天了。