<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDevelopment_Class%2FApplet_Loader</id>
		<title>Java/Development Class/Applet Loader - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDevelopment_Class%2FApplet_Loader"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Applet_Loader&amp;action=history"/>
		<updated>2026-04-18T20:25:47Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Development_Class/Applet_Loader&amp;diff=8405&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Applet_Loader&amp;diff=8405&amp;oldid=prev"/>
				<updated>2010-06-01T07:01:17Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 07:01, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Development_Class/Applet_Loader&amp;diff=8404&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Development_Class/Applet_Loader&amp;diff=8404&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Applet Loader Demo ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
import java.applet.Applet;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.InputStream;&lt;br /&gt;
import java.net.MalformedURLException;&lt;br /&gt;
import java.net.URL;&lt;br /&gt;
import java.net.URLConnection;&lt;br /&gt;
import java.util.Hashtable;&lt;br /&gt;
import javax.swing.JFrame;&lt;br /&gt;
public class MainClass {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    String name = &amp;quot;http://urlWithClassName&amp;quot;;&lt;br /&gt;
    try {&lt;br /&gt;
      if (!name.endsWith(&amp;quot;.class&amp;quot;)) {&lt;br /&gt;
        System.err.println(&amp;quot;That doesn&amp;quot;t look like a byte code file!&amp;quot;);&lt;br /&gt;
        return;&lt;br /&gt;
      }&lt;br /&gt;
      URL u = new URL(name);&lt;br /&gt;
      URLClassLoader ucl = new URLClassLoader(u);&lt;br /&gt;
      // parse out the name of the class from the URL&lt;br /&gt;
      String s = u.getFile();&lt;br /&gt;
      String classname = s.substring(s.lastIndexOf(&amp;quot;/&amp;quot;), s.lastIndexOf(&amp;quot;.class&amp;quot;));&lt;br /&gt;
      Class AppletClass = ucl.loadClass(classname, true);&lt;br /&gt;
      Applet apl = (Applet) AppletClass.newInstance();&lt;br /&gt;
      JFrame f = new JFrame();&lt;br /&gt;
      f.setSize(200, 200);&lt;br /&gt;
      f.add(&amp;quot;Center&amp;quot;, apl);&lt;br /&gt;
      apl.init();&lt;br /&gt;
      apl.start();&lt;br /&gt;
      f.setVisible(true);&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      System.err.println(e);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class URLClassLoader extends ClassLoader {&lt;br /&gt;
  Hashtable cache = new Hashtable();&lt;br /&gt;
  URL url;&lt;br /&gt;
  public URLClassLoader(URL u) {&lt;br /&gt;
    this.url = u;&lt;br /&gt;
  }&lt;br /&gt;
  public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {&lt;br /&gt;
    Class cls = (Class) cache.get(name);&lt;br /&gt;
    if (cls == null) {&lt;br /&gt;
      try {&lt;br /&gt;
        cls = findSystemClass(name);&lt;br /&gt;
      } catch (ClassNotFoundException e) {&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    if (cls == null) {&lt;br /&gt;
      byte classData[] = loadClassData(name);&lt;br /&gt;
      cls = defineClass(classData, 0, classData.length);&lt;br /&gt;
      cache.put(name, cls);&lt;br /&gt;
    }&lt;br /&gt;
    if (resolve) {&lt;br /&gt;
      resolveClass(cls);&lt;br /&gt;
    }&lt;br /&gt;
    return cls;&lt;br /&gt;
  }&lt;br /&gt;
  private byte[] loadClassData(String name) throws ClassNotFoundException {&lt;br /&gt;
    byte[] buffer;&lt;br /&gt;
    InputStream theClassInputStream = null;&lt;br /&gt;
    int bufferLength = 128;&lt;br /&gt;
    try {&lt;br /&gt;
      URL classURL = new URL(url, name + &amp;quot;.class&amp;quot;);&lt;br /&gt;
      URLConnection uc = classURL.openConnection();&lt;br /&gt;
      uc.setAllowUserInteraction(false);&lt;br /&gt;
      try {&lt;br /&gt;
        theClassInputStream = uc.getInputStream();&lt;br /&gt;
      } catch (NullPointerException e) {&lt;br /&gt;
        System.err.println(e);&lt;br /&gt;
        throw new ClassNotFoundException(name + &amp;quot; input stream problem&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      int contentLength = uc.getContentLength();&lt;br /&gt;
      // A lot of web servers don&amp;quot;t send content-lengths&lt;br /&gt;
      // for .class files&lt;br /&gt;
      if (contentLength == -1) {&lt;br /&gt;
        buffer = new byte[bufferLength * 16];&lt;br /&gt;
      } else {&lt;br /&gt;
        buffer = new byte[contentLength];&lt;br /&gt;
      }&lt;br /&gt;
      int bytesRead = 0;&lt;br /&gt;
      int offset = 0;&lt;br /&gt;
      while (bytesRead &amp;gt;= 0) {&lt;br /&gt;
        bytesRead = theClassInputStream.read(buffer, offset, bufferLength);&lt;br /&gt;
        if (bytesRead == -1)&lt;br /&gt;
          break;&lt;br /&gt;
        offset += bytesRead;&lt;br /&gt;
        if (contentLength == -1 &amp;amp;&amp;amp; offset == buffer.length) { // grow the array&lt;br /&gt;
          byte temp[] = new byte[offset * 2];&lt;br /&gt;
          System.arraycopy(buffer, 0, temp, 0, offset);&lt;br /&gt;
          buffer = temp;&lt;br /&gt;
        } else if (offset &amp;gt; buffer.length) {&lt;br /&gt;
          throw new ClassNotFoundException(name + &amp;quot; error reading data into the array&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      if (offset &amp;lt; buffer.length) { // shrink the array&lt;br /&gt;
        byte temp[] = new byte[offset];&lt;br /&gt;
        System.arraycopy(buffer, 0, temp, 0, offset);&lt;br /&gt;
        buffer = temp;&lt;br /&gt;
      }&lt;br /&gt;
      // Make sure all the bytes were received&lt;br /&gt;
      if (contentLength != -1 &amp;amp;&amp;amp; offset != contentLength) {&lt;br /&gt;
        throw new ClassNotFoundException(&amp;quot;Only &amp;quot; + offset + &amp;quot; bytes received for &amp;quot; + name&lt;br /&gt;
            + &amp;quot;\n Expected &amp;quot; + contentLength + &amp;quot; bytes&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    } catch (Exception e) {&lt;br /&gt;
      throw new ClassNotFoundException(name + &amp;quot; &amp;quot; + e);&lt;br /&gt;
    } finally {&lt;br /&gt;
      try {&lt;br /&gt;
        if (theClassInputStream != null)&lt;br /&gt;
          theClassInputStream.close();&lt;br /&gt;
      } catch (IOException e) {&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return buffer;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
         &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Dummy Applet Context ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
/**&lt;br /&gt;
 * Copyright(c) 1996 DTAI, Incorporated (http://www.dtai.ru)&lt;br /&gt;
 *&lt;br /&gt;
 *                        All rights reserved&lt;br /&gt;
 *&lt;br /&gt;
 * Permission to use, copy, modify and distribute this material for&lt;br /&gt;
 * any purpose and without fee is hereby granted, provided that the&lt;br /&gt;
 * above copyright notice and this permission notice appear in all&lt;br /&gt;
 * copies, and that the name of DTAI, Incorporated not be used in&lt;br /&gt;
 * advertising or publicity pertaining to this material without the&lt;br /&gt;
 * specific, prior written permission of an authorized representative of&lt;br /&gt;
 * DTAI, Incorporated.&lt;br /&gt;
 *&lt;br /&gt;
 * DTAI, INCORPORATED MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES,&lt;br /&gt;
 * EXPRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT&lt;br /&gt;
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND&lt;br /&gt;
 * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST&lt;br /&gt;
 * INFRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS.  THE&lt;br /&gt;
 * SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, AND IN NO EVENT SHALL DTAI, INCORPORATED OR&lt;br /&gt;
 * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY&lt;br /&gt;
 * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELATING&lt;br /&gt;
 * TO THE SOFTWARE.&lt;br /&gt;
 */&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.applet.*;&lt;br /&gt;
import java.net.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
/**&lt;br /&gt;
 * DummyAppletContext - implements AppletContext and AppletStub to allow any&lt;br /&gt;
 * applet to easily run as an application.  The only thing it can&amp;quot;t do is&lt;br /&gt;
 * access URL&amp;quot;s.  Applet parameters are entered on the command line with&lt;br /&gt;
 * name as one word and value as the next.&lt;br /&gt;
 *&lt;br /&gt;
 * @version 1.1&lt;br /&gt;
 * @author  DTAI, Incorporated&lt;br /&gt;
 *&lt;br /&gt;
 * $Id: DummyAppletContext.java,v 1.5 1996/10/08 21:15:09 kadel Exp $&lt;br /&gt;
 *&lt;br /&gt;
 * $Source: /cvs/java/classes/COM/dtai/gui/DummyAppletContext.java,v $&lt;br /&gt;
 */&lt;br /&gt;
public class DummyAppletContext&lt;br /&gt;
    extends Frame&lt;br /&gt;
    implements AppletStub, AppletContext, URLStreamHandlerFactory {&lt;br /&gt;
    private TextField status;&lt;br /&gt;
    private Hashtable params = new Hashtable();&lt;br /&gt;
    private Vector applets = new Vector();&lt;br /&gt;
    private int initial_width;&lt;br /&gt;
    private int initial_height;&lt;br /&gt;
  /**&lt;br /&gt;
   * Entry point into the standalone program.&lt;br /&gt;
   *&lt;br /&gt;
   * @param args  the command line arguments&lt;br /&gt;
   */&lt;br /&gt;
    public static void main ( String args[] ) {&lt;br /&gt;
        new DummyAppletContext( args );&lt;br /&gt;
    }&lt;br /&gt;
  /**&lt;br /&gt;
   * Constructor for the main class, given an existing applet object.&lt;br /&gt;
   *&lt;br /&gt;
   * @param applet            the applet embedded in this AppletContext&lt;br /&gt;
   * @param args              the command line arguments.  Contains possibly&lt;br /&gt;
   *                          height and width, and any applet parameters&lt;br /&gt;
   */&lt;br /&gt;
    public DummyAppletContext( Applet applet, String args[] ) {&lt;br /&gt;
        this( applet, 640, 480, args );&lt;br /&gt;
    }&lt;br /&gt;
  /**&lt;br /&gt;
   * Constructor for the main class, given an existing applet object and a default&lt;br /&gt;
   * frame (window) width and height.&lt;br /&gt;
   *&lt;br /&gt;
   * @param applet            the applet embedded in this AppletContext&lt;br /&gt;
   * @param default_width     the default width of the window&lt;br /&gt;
   * @param default_height    the default width of the window&lt;br /&gt;
   * @param args              the command line arguments.  Contains possibly&lt;br /&gt;
   *                          height and width, and any applet parameters&lt;br /&gt;
   */&lt;br /&gt;
    public DummyAppletContext( Applet applet, int default_width, int default_height,&lt;br /&gt;
                               String args[] ) {&lt;br /&gt;
        super ( applet.getClass().getName() );&lt;br /&gt;
        init( applet, default_width, default_height, args, 0 );&lt;br /&gt;
    }&lt;br /&gt;
  /**&lt;br /&gt;
   * Constructor for the main class, from the command line arguments.&lt;br /&gt;
   *&lt;br /&gt;
   * @param args  the command line arguments.  Contains the name of the applet&lt;br /&gt;
   *              class, possibly height and width, and any applet parameters.&lt;br /&gt;
   */&lt;br /&gt;
    public DummyAppletContext( String args[] ) {&lt;br /&gt;
        super ( args[0] );&lt;br /&gt;
        try {&lt;br /&gt;
            Applet applet = (Applet)Class.forName( args[0] ).newInstance();&lt;br /&gt;
            init( applet, 640, 480, args, 1 );&lt;br /&gt;
        }&lt;br /&gt;
        catch ( Exception e ) {&lt;br /&gt;
            e.printStackTrace();&lt;br /&gt;
            System.exit( 1 );&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  /*&lt;br /&gt;
   * PRIVATE initialization function.&lt;br /&gt;
   *&lt;br /&gt;
   * @param applet            the applet embedded in this AppletContext&lt;br /&gt;
   * @param default_width     the default width of the window&lt;br /&gt;
   * @param default_height    the default width of the window&lt;br /&gt;
   * @param args              the command line arguments.  Contains possibly&lt;br /&gt;
   *                          height and width, and any applet parameters&lt;br /&gt;
   * @param startidx          index in the args array at which to start parsing&lt;br /&gt;
   */&lt;br /&gt;
    private void init( Applet applet, int default_width, int default_height,&lt;br /&gt;
                       String args[], int startidx ) {&lt;br /&gt;
        URL.setURLStreamHandlerFactory( this );&lt;br /&gt;
        applets.addElement( applet );&lt;br /&gt;
        applet.setStub(this);&lt;br /&gt;
        initial_width = default_width;&lt;br /&gt;
        initial_height = default_height;&lt;br /&gt;
        parseArgs( args, startidx );&lt;br /&gt;
        status = new TextField();&lt;br /&gt;
        status.setEditable( false );&lt;br /&gt;
        add( &amp;quot;Center&amp;quot;, applet );&lt;br /&gt;
        add( &amp;quot;South&amp;quot;, status );&lt;br /&gt;
        appletResize( initial_width, initial_height );&lt;br /&gt;
        show();&lt;br /&gt;
        applet.init();&lt;br /&gt;
        applet.start();&lt;br /&gt;
    }&lt;br /&gt;
  /**&lt;br /&gt;
   * Parse the command line arguments.  Get the initial width and height of&lt;br /&gt;
   * the window if specified (-width [value] -height [value]), and the&lt;br /&gt;
   * applet parameters (name value pairs).&lt;br /&gt;
   *&lt;br /&gt;
   * @param args              the command line arguments.  Contains possibly&lt;br /&gt;
   *                          height and width, and any applet parameters&lt;br /&gt;
   * @param startidx          index in the args array at which to start parsing&lt;br /&gt;
   */&lt;br /&gt;
    public void parseArgs( String args[], int startidx ) {&lt;br /&gt;
        for ( int idx = startidx; idx &amp;lt; ( args.length - startidx ); idx+=2 ) {&lt;br /&gt;
            try {&lt;br /&gt;
                if ( args[idx].equals( &amp;quot;-width&amp;quot; ) ) {&lt;br /&gt;
                    initial_width = Integer.parseInt( args[idx+1] );&lt;br /&gt;
                }&lt;br /&gt;
                else if ( args[idx].equals( &amp;quot;-height&amp;quot; ) ) {&lt;br /&gt;
                    initial_height = Integer.parseInt( args[idx+1] );&lt;br /&gt;
                }&lt;br /&gt;
                else {&lt;br /&gt;
                    params.put( args[idx], args[idx+1] );&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            catch ( NumberFormatException nfe ) {&lt;br /&gt;
                System.err.println(&amp;quot;Warning: command line argument &amp;quot;+args[idx]+&lt;br /&gt;
                                   &amp;quot; is not a valid number.&amp;quot; );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
  /**&lt;br /&gt;
   * Event handler to catch the Frame (window) close action,&lt;br /&gt;
   * and exit the program.&lt;br /&gt;
   *&lt;br /&gt;
   * @param evt   The event that occurred&lt;br /&gt;
   * @return      false if the event was not handled by this object.&lt;br /&gt;
   */&lt;br /&gt;
    public boolean handleEvent( Event evt ) {&lt;br /&gt;
        if ( evt.id == Event.WINDOW_DESTROY ) {&lt;br /&gt;
            System.exit(0);&lt;br /&gt;
        }&lt;br /&gt;
        return super.handleEvent(evt);&lt;br /&gt;
    }&lt;br /&gt;
/************ AppletStub methods *************/&lt;br /&gt;
    /**&lt;br /&gt;
     * Returns true if the applet is active.&lt;br /&gt;
     *&lt;br /&gt;
     * @return  always true&lt;br /&gt;
     */&lt;br /&gt;
    public boolean isActive() { return true; }&lt;br /&gt;
    /**&lt;br /&gt;
     * Gets the document URL.&lt;br /&gt;
     *&lt;br /&gt;
   * @return      a &amp;quot;file:&amp;quot; URL for the current directory&lt;br /&gt;
     */&lt;br /&gt;
    public URL getDocumentBase() {&lt;br /&gt;
        URL url = null;&lt;br /&gt;
        try {&lt;br /&gt;
            File dummy = new File( &amp;quot;dummy.html&amp;quot; );&lt;br /&gt;
            String path = dummy.getAbsolutePath();&lt;br /&gt;
            if ( ! File.separator.equals( &amp;quot;/&amp;quot; ) ) {&lt;br /&gt;
                StringBuffer buffer = new StringBuffer();&lt;br /&gt;
                if ( path.charAt(0) != File.separator.charAt(0) ) {&lt;br /&gt;
                    buffer.append( &amp;quot;/&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
                StringTokenizer st = new StringTokenizer( path, File.separator );&lt;br /&gt;
                while ( st.hasMoreTokens() ) {&lt;br /&gt;
                    buffer.append( st.nextToken() + &amp;quot;/&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
                if ( File.separator.equals( &amp;quot;\\&amp;quot; ) &amp;amp;&amp;amp;&lt;br /&gt;
                     ( buffer.charAt(2) == &amp;quot;:&amp;quot; ) ) {&lt;br /&gt;
                    buffer.setCharAt( 2, &amp;quot;|&amp;quot; );&lt;br /&gt;
                }&lt;br /&gt;
                else {&lt;br /&gt;
                }&lt;br /&gt;
                path = buffer.toString();&lt;br /&gt;
                path = path.substring( 0, path.length()-1 );&lt;br /&gt;
            }&lt;br /&gt;
            url = new URL( &amp;quot;file&amp;quot;, &amp;quot;&amp;quot;, -1, path );&lt;br /&gt;
        }&lt;br /&gt;
        catch ( MalformedURLException mue ) {&lt;br /&gt;
            mue.printStackTrace();&lt;br /&gt;
        }&lt;br /&gt;
        return url;&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Gets the codebase URL.&lt;br /&gt;
     *&lt;br /&gt;
   * @return      in this case, the same value as getDocumentBase()&lt;br /&gt;
     */&lt;br /&gt;
    public final URL getCodeBase() { return getDocumentBase(); }&lt;br /&gt;
    /**&lt;br /&gt;
     * Gets a parameter of the applet.&lt;br /&gt;
     *&lt;br /&gt;
   * @param name  the name of the parameter&lt;br /&gt;
   * @return      the value, or null if not defined&lt;br /&gt;
   */&lt;br /&gt;
    public final String getParameter( String name ) {&lt;br /&gt;
        return (String)params.get( name );&lt;br /&gt;
    }&lt;br /&gt;
  /**&lt;br /&gt;
   * Gets a handler to the applet&amp;quot;s context.&lt;br /&gt;
   *&lt;br /&gt;
   * @return  this object&lt;br /&gt;
   */&lt;br /&gt;
    public final AppletContext getAppletContext() { return this; }&lt;br /&gt;
  /**&lt;br /&gt;
   * Called when the applet wants to be resized.  This causes the&lt;br /&gt;
   * Frame (window) to be resized to accomodate the new Applet size.&lt;br /&gt;
   *&lt;br /&gt;
   * @param width     the new width of the applet&lt;br /&gt;
   * @param height    the new height of the applet&lt;br /&gt;
   */&lt;br /&gt;
    public void appletResize( int width, int height ) {&lt;br /&gt;
        Insets insets = insets();&lt;br /&gt;
        resize( ( width + insets.left + insets.right ),&lt;br /&gt;
                ( height + status.preferredSize().height +&lt;br /&gt;
                  insets.top + insets.bottom ) );&lt;br /&gt;
    }&lt;br /&gt;
/************ AppletContext methods *************/&lt;br /&gt;
  /**&lt;br /&gt;
     * Gets an audio clip.  (There doesn&amp;quot;t seem to be a &amp;quot;Toolkit&amp;quot; for&lt;br /&gt;
     * audio clips in my JDK, so this always returns null.  You could&lt;br /&gt;
     * implement this differently, returning a dummy AudioClip object&lt;br /&gt;
     * for which the class could be defined at the bottom of this file.)&lt;br /&gt;
   *&lt;br /&gt;
   * @param url   URL of the AudioClip to load&lt;br /&gt;
   * @return      the AudioClip object if it exists (in our case,&lt;br /&gt;
   *              this is always null&lt;br /&gt;
   */&lt;br /&gt;
    public final AudioClip getAudioClip( URL url ) { return null; }&lt;br /&gt;
  /**&lt;br /&gt;
     * Gets an image. This usually involves downloading it&lt;br /&gt;
     * over the net. However, the environment may decide to&lt;br /&gt;
     * cache images. This method takes an array of URLs,&lt;br /&gt;
     * each of which will be tried until the image is found.&lt;br /&gt;
   *&lt;br /&gt;
   * @param url   URL of the Image to load&lt;br /&gt;
   * @return      the Image object&lt;br /&gt;
   */&lt;br /&gt;
    public final Image getImage( URL url ) {&lt;br /&gt;
        return Toolkit.getDefaultToolkit().getImage( filenameFromURL( url ) );&lt;br /&gt;
    }&lt;br /&gt;
  /*&lt;br /&gt;
     * PRIVATE utility function.  Ignores the protocol, and returns a&lt;br /&gt;
     * filename for a file on the local filesystem (which may or may&lt;br /&gt;
     * not exist, of course).&lt;br /&gt;
   *&lt;br /&gt;
   * @param url   URL to be converted to a filename on the local&lt;br /&gt;
   *              filesystem.&lt;br /&gt;
   * @return      the filename&lt;br /&gt;
   */&lt;br /&gt;
    private String filenameFromURL( URL url ) {&lt;br /&gt;
        String filename = url.getFile();&lt;br /&gt;
        if ( filename.charAt(1) == &amp;quot;|&amp;quot; ) {&lt;br /&gt;
            StringBuffer buf = new StringBuffer( filename );&lt;br /&gt;
            buf.setCharAt( 1, &amp;quot;:&amp;quot; );&lt;br /&gt;
            filename = buf.toString();&lt;br /&gt;
        }&lt;br /&gt;
        else if ( filename.charAt(2) == &amp;quot;|&amp;quot; ) {&lt;br /&gt;
            StringBuffer buf = new StringBuffer( filename );&lt;br /&gt;
            buf.setCharAt( 2, &amp;quot;:&amp;quot; );&lt;br /&gt;
            filename = buf.toString();&lt;br /&gt;
        }&lt;br /&gt;
        return filename;&lt;br /&gt;
    }&lt;br /&gt;
  /**&lt;br /&gt;
     * Gets an applet by name.&lt;br /&gt;
     *&lt;br /&gt;
   * @param name  the name of the applet&lt;br /&gt;
     * @return      null if the applet does not exist, and it never&lt;br /&gt;
     *              does since we never name the applet.&lt;br /&gt;
   */&lt;br /&gt;
    public final Applet getApplet( String name ) { return null; }&lt;br /&gt;
  /**&lt;br /&gt;
     * Enumerates the applets in this context. Only applets&lt;br /&gt;
     * that are accessible will be returned. This list always&lt;br /&gt;
     * includes the applet itself.&lt;br /&gt;
   *&lt;br /&gt;
   * @return  the Enumeration -- contains ONLY the applet created with&lt;br /&gt;
   *          this DummyAppletContext&lt;br /&gt;
   */&lt;br /&gt;
    public final Enumeration getApplets() { return applets.elements(); }&lt;br /&gt;
  /**&lt;br /&gt;
     * Shows a new document. This may be ignored by&lt;br /&gt;
     * the applet context (and in our case, it is, but we&amp;quot;ll show the&lt;br /&gt;
     * user, in the status area, that the document was requested and&lt;br /&gt;
     * WOULD be loaded if in a browser).&lt;br /&gt;
   *&lt;br /&gt;
   * @param url   URL to load&lt;br /&gt;
   */&lt;br /&gt;
    public void showDocument( URL url ) {&lt;br /&gt;
        status.setText( &amp;quot;AppletContext request to show URL &amp;quot; +&lt;br /&gt;
                        url.toString() );&lt;br /&gt;
    }&lt;br /&gt;
  /**&lt;br /&gt;
     * Show a new document in a target window or frame. This may be ignored by&lt;br /&gt;
     * the applet context.  (Again, it is ignored, but we&amp;quot;ll show the&lt;br /&gt;
     * request information to the user in the status area.)&lt;br /&gt;
     *&lt;br /&gt;
     * This method accepts the target strings:&lt;br /&gt;
     *   _self    show in current frame&lt;br /&gt;
     *   _parent  show in parent frame&lt;br /&gt;
     *   _top   show in top-most frame&lt;br /&gt;
     *   _blank   show in new unnamed top-level window&lt;br /&gt;
     *   &amp;lt;other&amp;gt;  show in new top-level window named &amp;lt;other&amp;gt;&lt;br /&gt;
   *&lt;br /&gt;
   * @param url       URL to load&lt;br /&gt;
   * @param target    the target string&lt;br /&gt;
   */&lt;br /&gt;
    public void showDocument( URL url, String target ) {&lt;br /&gt;
        status.setText( &amp;quot;AppletContext request to show URL &amp;quot; +&lt;br /&gt;
                        url.toString() +&lt;br /&gt;
                        &amp;quot; in target: &amp;quot; + target );&lt;br /&gt;
    }&lt;br /&gt;
  /**&lt;br /&gt;
     * Show a status string in the status area (the Text object at the bottom&lt;br /&gt;
     * of the window.&lt;br /&gt;
   *&lt;br /&gt;
   * @param text  the text to display&lt;br /&gt;
   */&lt;br /&gt;
    public void showStatus( String text ) { status.setText( text ); }&lt;br /&gt;
/************ URLStreamHandlerFactory methods *************/&lt;br /&gt;
  /**&lt;br /&gt;
     * Creates a new URLStreamHandler instance with the specified protocol.&lt;br /&gt;
     *&lt;br /&gt;
     * @param protocol  the protocol to use (ftp, http, nntp, etc.).&lt;br /&gt;
     *                  THIS PROTOCOL IS IGNORED BY THIS APPLET CONTEXT&lt;br /&gt;
     */&lt;br /&gt;
    public URLStreamHandler createURLStreamHandler( String protocol ) {&lt;br /&gt;
        return new DummyURLStreamHandler();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * A URL stream handler for all protocols, used to return our&lt;br /&gt;
 * dummy implementation of URLConnection to open up a local&lt;br /&gt;
 * file when called upon.&lt;br /&gt;
 */&lt;br /&gt;
class DummyURLStreamHandler extends URLStreamHandler {&lt;br /&gt;
    protected final URLConnection openConnection( URL u ) throws IOException {&lt;br /&gt;
        return new DummyURLConnection( u );&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * Our dummy implementation of URLConnection used to open up a local&lt;br /&gt;
 * file when called upon with a given URL of ANY protocol type.  This&lt;br /&gt;
 * allows the applet to easily use the &amp;quot;getInputStream()&amp;quot; function.&lt;br /&gt;
 */&lt;br /&gt;
class DummyURLConnection extends URLConnection {&lt;br /&gt;
    boolean connected = false;&lt;br /&gt;
    InputStream instream;&lt;br /&gt;
    /*&lt;br /&gt;
     * Constructor for the DummyURLConnection&lt;br /&gt;
     */&lt;br /&gt;
    protected DummyURLConnection( URL url ) {&lt;br /&gt;
        super( url );&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * open the local file&lt;br /&gt;
     */&lt;br /&gt;
    public void connect() throws IOException {&lt;br /&gt;
        if ( ! connected ) {&lt;br /&gt;
            String filename = url.getFile();&lt;br /&gt;
            if ( filename.charAt(1) == &amp;quot;|&amp;quot; ) {&lt;br /&gt;
                StringBuffer buf = new StringBuffer( filename );&lt;br /&gt;
                buf.setCharAt( 1, &amp;quot;:&amp;quot; );&lt;br /&gt;
                filename = buf.toString();&lt;br /&gt;
            }&lt;br /&gt;
            else if ( filename.charAt(2) == &amp;quot;|&amp;quot; ) {&lt;br /&gt;
                StringBuffer buf = new StringBuffer( filename );&lt;br /&gt;
                buf.setCharAt( 2, &amp;quot;:&amp;quot; );&lt;br /&gt;
                filename = buf.toString();&lt;br /&gt;
            }&lt;br /&gt;
            instream = new FileInputStream( filename );&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * return the open stream to the local file (open if necessary).&lt;br /&gt;
     */&lt;br /&gt;
    public InputStream getInputStream() throws IOException {&lt;br /&gt;
        if ( ! connected ) {&lt;br /&gt;
            connect();&lt;br /&gt;
        }&lt;br /&gt;
        if ( instream == null ) {&lt;br /&gt;
            throw new IOException();&lt;br /&gt;
        }&lt;br /&gt;
        return instream;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>