src/java.desktop/share/classes/sun/applet/AppletPanel.java

Print this page




  55  * destroy() methods.
  56  *
  57  * @author      Arthur van Hoff
  58  */
  59 @SuppressWarnings("serial") // JDK implementation class
  60 public
  61 abstract class AppletPanel extends Panel implements AppletStub, Runnable {
  62 
  63     /**
  64      * The applet (if loaded).
  65      */
  66     Applet applet;
  67 
  68 
  69     /**
  70      * The classloader for the applet.
  71      */
  72     protected AppletClassLoader loader;
  73 
  74     /* applet event ids */
  75     public final static int APPLET_DISPOSE = 0;
  76     public final static int APPLET_LOAD = 1;
  77     public final static int APPLET_INIT = 2;
  78     public final static int APPLET_START = 3;
  79     public final static int APPLET_STOP = 4;
  80     public final static int APPLET_DESTROY = 5;
  81     public final static int APPLET_QUIT = 6;
  82     public final static int APPLET_ERROR = 7;
  83 
  84     /* send to the parent to force relayout */
  85     public final static int APPLET_RESIZE = 51234;
  86 
  87     /* sent to a (distant) parent to indicate that the applet is being
  88      * loaded or as completed loading
  89      */
  90     public final static int APPLET_LOADING = 51235;
  91     public final static int APPLET_LOADING_COMPLETED = 51236;
  92 
  93     /**
  94      * The current status. One of:
  95      *    APPLET_DISPOSE,
  96      *    APPLET_LOAD,
  97      *    APPLET_INIT,
  98      *    APPLET_START,
  99      *    APPLET_STOP,
 100      *    APPLET_DESTROY,
 101      *    APPLET_ERROR.
 102      */
 103     protected int status;
 104 
 105     /**
 106      * The thread for the applet.
 107      */
 108     protected Thread handler;
 109 
 110 
 111     /**


 115 
 116     /**
 117      * The current applet size.
 118      */
 119     Dimension currentAppletSize = new Dimension(10, 10);
 120 
 121     MessageUtils mu = new MessageUtils();
 122 
 123     /**
 124      * The thread to use during applet loading
 125      */
 126 
 127     Thread loaderThread = null;
 128 
 129     /**
 130      * Flag to indicate that a loading has been cancelled
 131      */
 132     boolean loadAbortRequest = false;
 133 
 134     /* abstract classes */
 135     abstract protected String getCode();
 136     abstract protected String getJarFiles();
 137 
 138     @Override
 139     abstract public int    getWidth();
 140     @Override
 141     abstract public int    getHeight();
 142     abstract public boolean hasInitialFocus();
 143 
 144     private static int threadGroupNumber = 0;
 145 
 146     protected void setupAppletAppContext() {
 147         // do nothing
 148     }
 149 
 150     /*
 151      * Creates a thread to run the applet. This method is called
 152      * each time an applet is loaded and reloaded.
 153      */
 154     synchronized void createAppletThread() {
 155         // Create a thread group for the applet, and start a new
 156         // thread to load the applet.
 157         String nm = "applet-" + getCode();
 158         loader = getClassLoader(getCodeBase(), getClassLoaderCacheKey());
 159         loader.grab(); // Keep this puppy around!
 160 
 161         // 4668479: Option to turn off codebase lookup in AppletClassLoader
 162         // during resource requests. [stanley.ho]


 233     }
 234 
 235     /**
 236      * Preferred size
 237      */
 238     @Override
 239     @SuppressWarnings("deprecation")
 240     public Dimension preferredSize() {
 241         return new Dimension(currentAppletSize.width,
 242                              currentAppletSize.height);
 243     }
 244 
 245     private AppletListener listeners;
 246 
 247     /**
 248      * AppletEvent Queue
 249      */
 250     private Queue<Integer> queue = null;
 251 
 252 
 253     synchronized public void addAppletListener(AppletListener l) {
 254         listeners = AppletEventMulticaster.add(listeners, l);
 255     }
 256 
 257     synchronized public void removeAppletListener(AppletListener l) {
 258         listeners = AppletEventMulticaster.remove(listeners, l);
 259     }
 260 
 261     /**
 262      * Dispatch event to the listeners..
 263      */
 264     public void dispatchAppletEvent(int id, Object argument) {
 265         //System.out.println("SEND= " + id);
 266         if (listeners != null) {
 267             AppletEvent evt = new AppletEvent(this, id, argument);
 268             listeners.appletStateChanged(evt);
 269         }
 270     }
 271 
 272     /**
 273      * Send an event. Queue it for execution by the handler thread.
 274      */
 275     public void sendEvent(int id) {
 276         synchronized(this) {
 277             if (queue == null) {




  55  * destroy() methods.
  56  *
  57  * @author      Arthur van Hoff
  58  */
  59 @SuppressWarnings("serial") // JDK implementation class
  60 public
  61 abstract class AppletPanel extends Panel implements AppletStub, Runnable {
  62 
  63     /**
  64      * The applet (if loaded).
  65      */
  66     Applet applet;
  67 
  68 
  69     /**
  70      * The classloader for the applet.
  71      */
  72     protected AppletClassLoader loader;
  73 
  74     /* applet event ids */
  75     public static final int APPLET_DISPOSE = 0;
  76     public static final int APPLET_LOAD = 1;
  77     public static final int APPLET_INIT = 2;
  78     public static final int APPLET_START = 3;
  79     public static final int APPLET_STOP = 4;
  80     public static final int APPLET_DESTROY = 5;
  81     public static final int APPLET_QUIT = 6;
  82     public static final int APPLET_ERROR = 7;
  83 
  84     /* send to the parent to force relayout */
  85     public static final int APPLET_RESIZE = 51234;
  86 
  87     /* sent to a (distant) parent to indicate that the applet is being
  88      * loaded or as completed loading
  89      */
  90     public static final int APPLET_LOADING = 51235;
  91     public static final int APPLET_LOADING_COMPLETED = 51236;
  92 
  93     /**
  94      * The current status. One of:
  95      *    APPLET_DISPOSE,
  96      *    APPLET_LOAD,
  97      *    APPLET_INIT,
  98      *    APPLET_START,
  99      *    APPLET_STOP,
 100      *    APPLET_DESTROY,
 101      *    APPLET_ERROR.
 102      */
 103     protected int status;
 104 
 105     /**
 106      * The thread for the applet.
 107      */
 108     protected Thread handler;
 109 
 110 
 111     /**


 115 
 116     /**
 117      * The current applet size.
 118      */
 119     Dimension currentAppletSize = new Dimension(10, 10);
 120 
 121     MessageUtils mu = new MessageUtils();
 122 
 123     /**
 124      * The thread to use during applet loading
 125      */
 126 
 127     Thread loaderThread = null;
 128 
 129     /**
 130      * Flag to indicate that a loading has been cancelled
 131      */
 132     boolean loadAbortRequest = false;
 133 
 134     /* abstract classes */
 135     protected abstract String getCode();
 136     protected abstract String getJarFiles();
 137 
 138     @Override
 139     public abstract int    getWidth();
 140     @Override
 141     public abstract int    getHeight();
 142     public abstract boolean hasInitialFocus();
 143 
 144     private static int threadGroupNumber = 0;
 145 
 146     protected void setupAppletAppContext() {
 147         // do nothing
 148     }
 149 
 150     /*
 151      * Creates a thread to run the applet. This method is called
 152      * each time an applet is loaded and reloaded.
 153      */
 154     synchronized void createAppletThread() {
 155         // Create a thread group for the applet, and start a new
 156         // thread to load the applet.
 157         String nm = "applet-" + getCode();
 158         loader = getClassLoader(getCodeBase(), getClassLoaderCacheKey());
 159         loader.grab(); // Keep this puppy around!
 160 
 161         // 4668479: Option to turn off codebase lookup in AppletClassLoader
 162         // during resource requests. [stanley.ho]


 233     }
 234 
 235     /**
 236      * Preferred size
 237      */
 238     @Override
 239     @SuppressWarnings("deprecation")
 240     public Dimension preferredSize() {
 241         return new Dimension(currentAppletSize.width,
 242                              currentAppletSize.height);
 243     }
 244 
 245     private AppletListener listeners;
 246 
 247     /**
 248      * AppletEvent Queue
 249      */
 250     private Queue<Integer> queue = null;
 251 
 252 
 253     public synchronized void addAppletListener(AppletListener l) {
 254         listeners = AppletEventMulticaster.add(listeners, l);
 255     }
 256 
 257     public synchronized void removeAppletListener(AppletListener l) {
 258         listeners = AppletEventMulticaster.remove(listeners, l);
 259     }
 260 
 261     /**
 262      * Dispatch event to the listeners..
 263      */
 264     public void dispatchAppletEvent(int id, Object argument) {
 265         //System.out.println("SEND= " + id);
 266         if (listeners != null) {
 267             AppletEvent evt = new AppletEvent(this, id, argument);
 268             listeners.appletStateChanged(evt);
 269         }
 270     }
 271 
 272     /**
 273      * Send an event. Queue it for execution by the handler thread.
 274      */
 275     public void sendEvent(int id) {
 276         synchronized(this) {
 277             if (queue == null) {