pluginappletwindow.java

来自「gcj java applet的web browser 插件」· Java 代码 · 共 127 行

JAVA
127
字号
/* PluginAppletWindow.java -- an embeddable applet window   Copyright (C) 2003, 2004  Thomas Fitzsimmons <fitzsim@redhat.com>   This file is part of GCJ Applet Viewer.   GCJ Applet Viewer is free software; you can redistribute it and/or   modify it under the terms of the GNU General Public License as   published by the Free Software Foundation; either version 2 of the   License, or (at your option) any later version.   GCJ Applet Viewer is distributed in the hope that it will be   useful, but WITHOUT ANY WARRANTY; without even the implied warranty   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with GCJ Applet Viewer; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/package gnu.gcjwebplugin;import gnu.java.awt.EmbeddedWindow;import java.applet.Applet;import java.applet.AppletContext;import java.awt.AWTEvent;import java.awt.BorderLayout;import java.awt.Component;import java.awt.Dimension;import java.awt.Toolkit;import java.io.IOException;import java.io.StreamTokenizer;import java.io.StringReader;import java.net.MalformedURLException;import java.net.URL;import java.util.HashMap;class PluginAppletWindow extends EmbeddedWindow{  private static HashMap contexts = new HashMap();  private Applet applet;  private AppletTag tag;  private AppletWarning warning;  private boolean isActive;  PluginAppletWindow()  {    super();  }  void setTag(String tag, String documentbase, String encoding)    throws MalformedURLException, IOException  {    StringReader reader = new StringReader(tag);    URL documentbaseURL = AppletTag.locationToURL(documentbase);    this.tag =      AppletTag.parseNextTag(new StreamTokenizer(reader), documentbaseURL,                             encoding);  }  ///////////////////////////////////  ////// EmbeddedWindow Method //////  ///////////////////////////////////  /**   * Set the native handle of the window system to embed the window in.   *   * @param handle the native handle.   */  public void setHandle(long handle)  {    super.setHandle(handle);    addNotify();    setLayout(new BorderLayout());    applet = AppletViewer.createApplet(tag);    if (contexts.get(tag.codebase) == null)      contexts.put(tag.codebase, new PluginAppletContext());    isActive = true;    add(applet, BorderLayout.CENTER);    AppletContext context = (AppletContext) contexts.get(tag.codebase);    ((PluginAppletContext) context).addApplet(applet);    applet.setStub(new CommonAppletStub(tag, context, applet));    Dimension size = AppletTag.getSize (tag);    setSize (size.width, size.height);    applet.setSize (size);    // Initialize the applet before showing this window so that    // the applet doesn't receive events before it has been    // initialized.    applet.init ();    setVisible (true);    applet.validate();    applet.start();  }  /////////////////////////////  ////// Component Method /////  /////////////////////////////  /**   * Prompts the layout manager to lay out this component. This is usually   * called when the component (more specifically, container) is validated.   *   * (description copied from java.awt.Component.doLayout())   */  public void doLayout()  {    super.doLayout();    // Assume the applet to be our only child and give it all the    // space we have.    Component c = this.getComponent(0);    if (c != null)      {	Dimension cs = getSize();	c.setBounds(0, 0, cs.width, cs.height);      }  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?