133 } |
133 } |
134 this.stub = stub; |
134 this.stub = stub; |
135 } |
135 } |
136 |
136 |
137 /** |
137 /** |
138 * Determines if this applet is active. An applet is marked active |
138 * Determines if this applet is active. An applet is marked active just |
139 * just before its {@code start} method is called. It becomes |
139 * before its {@code start} method is called. It becomes inactive just |
140 * inactive just before its {@code stop} method is called. |
140 * before its {@code stop} method is called. |
141 * |
141 * |
142 * @return {@code true} if the applet is active; |
142 * @return {@code true} if the applet is active; {@code false} otherwise |
143 * {@code false} otherwise. |
143 * @see java.applet.Applet#start() |
144 * @see java.applet.Applet#start() |
144 * @see java.applet.Applet#stop() |
145 * @see java.applet.Applet#stop() |
|
146 */ |
145 */ |
147 public boolean isActive() { |
146 public boolean isActive() { |
148 if (stub != null) { |
147 if (stub != null) { |
149 return stub.isActive(); |
148 return stub.isActive(); |
150 } else { // If stub field not filled in, applet never active |
149 } else { // If stub field not filled in, applet never active |
151 return false; |
150 return false; |
152 } |
151 } |
153 } |
152 } |
154 |
153 |
155 /** |
154 /** |
156 * Gets the URL of the document in which this applet is embedded. |
155 * Gets the {@code URL} of the document in which this applet is embedded. |
157 * For example, suppose an applet is contained |
156 * For example, suppose an applet is contained within the document: |
158 * within the document: |
|
159 * <blockquote><pre> |
157 * <blockquote><pre> |
160 * http://www.oracle.com/technetwork/java/index.html |
158 * http://www.oracle.com/technetwork/java/index.html |
161 * </pre></blockquote> |
159 * </pre></blockquote> |
162 * The document base is: |
160 * The document base is: |
163 * <blockquote><pre> |
161 * <blockquote><pre> |
164 * http://www.oracle.com/technetwork/java/index.html |
162 * http://www.oracle.com/technetwork/java/index.html |
165 * </pre></blockquote> |
163 * </pre></blockquote> |
166 * |
164 * |
167 * @return the {@link java.net.URL} of the document that contains this |
165 * @return the {@link java.net.URL} of the document that contains this |
168 * applet. |
166 * applet |
169 * @see java.applet.Applet#getCodeBase() |
167 * @see java.applet.Applet#getCodeBase() |
170 */ |
168 */ |
171 public URL getDocumentBase() { |
169 public URL getDocumentBase() { |
172 return stub.getDocumentBase(); |
170 return stub.getDocumentBase(); |
173 } |
171 } |
174 |
172 |
175 /** |
173 /** |
176 * Gets the base URL. This is the URL of the directory which contains this applet. |
174 * Gets the base {@code URL}. This is the {@code URL} of the directory which |
177 * |
175 * contains this applet. |
178 * @return the base {@link java.net.URL} of |
176 * |
179 * the directory which contains this applet. |
177 * @return the base {@link java.net.URL} of the directory which contains |
180 * @see java.applet.Applet#getDocumentBase() |
178 * this applet |
|
179 * @see java.applet.Applet#getDocumentBase() |
181 */ |
180 */ |
182 public URL getCodeBase() { |
181 public URL getCodeBase() { |
183 return stub.getCodeBase(); |
182 return stub.getCodeBase(); |
184 } |
183 } |
185 |
184 |
186 /** |
185 /** |
187 * Returns the value of the named parameter in the HTML tag. For |
186 * Returns the value of the named parameter in the HTML tag. For example, if |
188 * example, if this applet is specified as |
187 * this applet is specified as |
189 * <blockquote><pre> |
188 * <blockquote><pre> |
190 * <applet code="Clock" width=50 height=50> |
189 * <applet code="Clock" width=50 height=50> |
191 * <param name=Color value="blue"> |
190 * <param name=Color value="blue"> |
192 * </applet> |
191 * </applet> |
193 * </pre></blockquote> |
192 * </pre></blockquote> |
194 * <p> |
193 * <p> |
195 * then a call to {@code getParameter("Color")} returns the |
194 * then a call to {@code getParameter("Color")} returns the value |
196 * value {@code "blue"}. |
195 * {@code "blue"}. |
197 * <p> |
196 * <p> |
198 * The {@code name} argument is case insensitive. |
197 * The {@code name} argument is case insensitive. |
199 * |
198 * |
200 * @param name a parameter name. |
199 * @param name a parameter name |
201 * @return the value of the named parameter, |
200 * @return the value of the named parameter, or {@code null} if not set |
202 * or {@code null} if not set. |
201 */ |
203 */ |
202 public String getParameter(String name) { |
204 public String getParameter(String name) { |
203 return stub.getParameter(name); |
205 return stub.getParameter(name); |
204 } |
206 } |
205 |
207 |
206 /** |
208 /** |
207 * Determines this applet's context, which allows the applet to query and |
209 * Determines this applet's context, which allows the applet to |
208 * affect the environment in which it runs. |
210 * query and affect the environment in which it runs. |
209 * <p> |
211 * <p> |
210 * This environment of an applet represents the document that contains the |
212 * This environment of an applet represents the document that |
211 * applet. |
213 * contains the applet. |
212 * |
214 * |
213 * @return the applet's context |
215 * @return the applet's context. |
|
216 */ |
214 */ |
217 public AppletContext getAppletContext() { |
215 public AppletContext getAppletContext() { |
218 return stub.getAppletContext(); |
216 return stub.getAppletContext(); |
219 } |
217 } |
220 |
218 |
221 /** |
219 /** |
222 * Requests that this applet be resized. |
220 * Requests that this applet be resized. |
223 * |
221 * |
224 * @param width the new requested width for the applet. |
222 * @param width the new requested width for the applet |
225 * @param height the new requested height for the applet. |
223 * @param height the new requested height for the applet |
226 */ |
224 */ |
227 @SuppressWarnings("deprecation") |
225 @SuppressWarnings("deprecation") |
228 public void resize(int width, int height) { |
226 public void resize(int width, int height) { |
229 Dimension d = size(); |
227 Dimension d = size(); |
230 if ((d.width != width) || (d.height != height)) { |
228 if ((d.width != width) || (d.height != height)) { |
250 * <p> |
248 * <p> |
251 * {@code Applet} objects are the validate roots, and, therefore, they |
249 * {@code Applet} objects are the validate roots, and, therefore, they |
252 * override this method to return {@code true}. |
250 * override this method to return {@code true}. |
253 * |
251 * |
254 * @return {@code true} |
252 * @return {@code true} |
|
253 * @see java.awt.Container#isValidateRoot |
255 * @since 1.7 |
254 * @since 1.7 |
256 * @see java.awt.Container#isValidateRoot |
|
257 */ |
255 */ |
258 @Override |
256 @Override |
259 public boolean isValidateRoot() { |
257 public boolean isValidateRoot() { |
260 return true; |
258 return true; |
261 } |
259 } |
262 |
260 |
263 /** |
261 /** |
264 * Requests that the argument string be displayed in the |
262 * Requests that the argument string be displayed in the "status window". |
265 * "status window". Many browsers and applet viewers |
263 * Many browsers and applet viewers provide such a window, where the |
266 * provide such a window, where the application can inform users of |
264 * application can inform users of its current state. |
267 * its current state. |
265 * |
268 * |
266 * @param msg a string to display in the status window |
269 * @param msg a string to display in the status window. |
|
270 */ |
267 */ |
271 public void showStatus(String msg) { |
268 public void showStatus(String msg) { |
272 getAppletContext().showStatus(msg); |
269 getAppletContext().showStatus(msg); |
273 } |
270 } |
274 |
271 |
275 /** |
272 /** |
276 * Returns an {@code Image} object that can then be painted on |
273 * Returns an {@code Image} object that can then be painted on the screen. |
277 * the screen. The {@code url} that is passed as an argument |
274 * The {@code url} that is passed as an argument must specify an absolute |
278 * must specify an absolute URL. |
275 * {@code URL}. |
279 * <p> |
276 * <p> |
280 * This method always returns immediately, whether or not the image |
277 * This method always returns immediately, whether or not the image exists. |
281 * exists. When this applet attempts to draw the image on the screen, |
278 * When this applet attempts to draw the image on the screen, the data will |
282 * the data will be loaded. The graphics primitives that draw the |
279 * be loaded. The graphics primitives that draw the image will incrementally |
283 * image will incrementally paint on the screen. |
280 * paint on the screen. |
284 * |
281 * |
285 * @param url an absolute URL giving the location of the image. |
282 * @param url an absolute {@code URL} giving the location of the image |
286 * @return the image at the specified URL. |
283 * @return the image at the specified {@code URL} |
287 * @see java.awt.Image |
284 * @see java.awt.Image |
288 */ |
285 */ |
289 public Image getImage(URL url) { |
286 public Image getImage(URL url) { |
290 return getAppletContext().getImage(url); |
287 return getAppletContext().getImage(url); |
291 } |
288 } |
292 |
289 |
293 /** |
290 /** |
294 * Returns an {@code Image} object that can then be painted on |
291 * Returns an {@code Image} object that can then be painted on the screen. |
295 * the screen. The {@code url} argument must specify an absolute |
292 * The {@code url} argument must specify an absolute {@code URL}. The |
296 * URL. The {@code name} argument is a specifier that is |
293 * {@code name} argument is a specifier that is relative to the {@code url} |
297 * relative to the {@code url} argument. |
294 * argument. |
298 * <p> |
295 * <p> |
299 * This method always returns immediately, whether or not the image |
296 * This method always returns immediately, whether or not the image exists. |
300 * exists. When this applet attempts to draw the image on the screen, |
297 * When this applet attempts to draw the image on the screen, the data will |
301 * the data will be loaded. The graphics primitives that draw the |
298 * be loaded. The graphics primitives that draw the image will incrementally |
302 * image will incrementally paint on the screen. |
299 * paint on the screen. |
303 * |
300 * |
304 * @param url an absolute URL giving the base location of the image. |
301 * @param url an absolute URL giving the base location of the image |
305 * @param name the location of the image, relative to the |
302 * @param name the location of the image, relative to the {@code url} |
306 * {@code url} argument. |
303 * argument |
307 * @return the image at the specified URL. |
304 * @return the image at the specified {@code URL} |
308 * @see java.awt.Image |
305 * @see java.awt.Image |
309 */ |
306 */ |
310 public Image getImage(URL url, String name) { |
307 public Image getImage(URL url, String name) { |
311 try { |
308 try { |
312 return getImage(new URL(url, name)); |
309 return getImage(new URL(url, name)); |
313 } catch (MalformedURLException e) { |
310 } catch (MalformedURLException e) { |
314 return null; |
311 return null; |
315 } |
312 } |
316 } |
313 } |
317 |
314 |
318 /** |
315 /** |
319 * Get an audio clip from the given URL. |
316 * Get an audio clip from the given {@code URL}. |
320 * |
317 * |
321 * @param url points to the audio clip |
318 * @param url points to the audio clip |
322 * @return the audio clip at the specified URL. |
319 * @return the audio clip at the specified {@code URL} |
323 * |
320 * @since 1.2 |
324 * @since 1.2 |
|
325 */ |
321 */ |
326 public static final AudioClip newAudioClip(URL url) { |
322 public static final AudioClip newAudioClip(URL url) { |
327 return JavaSoundAudioClip.create(url); |
323 return JavaSoundAudioClip.create(url); |
328 } |
324 } |
329 |
325 |
330 /** |
326 /** |
331 * Returns the {@code AudioClip} object specified by the |
327 * Returns the {@code AudioClip} object specified by the {@code URL} |
332 * {@code URL} argument. |
328 * argument. |
333 * <p> |
329 * <p> |
334 * This method always returns immediately, whether or not the audio |
330 * This method always returns immediately, whether or not the audio clip |
335 * clip exists. When this applet attempts to play the audio clip, the |
331 * exists. When this applet attempts to play the audio clip, the data will |
336 * data will be loaded. |
332 * be loaded. |
337 * |
333 * |
338 * @param url an absolute URL giving the location of the audio clip. |
334 * @param url an absolute {@code URL} giving the location of the audio clip |
339 * @return the audio clip at the specified URL. |
335 * @return the audio clip at the specified {@code URL} |
340 * @see java.applet.AudioClip |
336 * @see java.applet.AudioClip |
341 */ |
337 */ |
342 public AudioClip getAudioClip(URL url) { |
338 public AudioClip getAudioClip(URL url) { |
343 return getAppletContext().getAudioClip(url); |
339 return getAppletContext().getAudioClip(url); |
344 } |
340 } |
345 |
341 |
346 /** |
342 /** |
347 * Returns the {@code AudioClip} object specified by the |
343 * Returns the {@code AudioClip} object specified by the {@code URL} and |
348 * {@code URL} and {@code name} arguments. |
344 * {@code name} arguments. |
349 * <p> |
345 * <p> |
350 * This method always returns immediately, whether or not the audio |
346 * This method always returns immediately, whether or not the audio clip |
351 * clip exists. When this applet attempts to play the audio clip, the |
347 * exists. When this applet attempts to play the audio clip, the data will |
352 * data will be loaded. |
348 * be loaded. |
353 * |
349 * |
354 * @param url an absolute URL giving the base location of the |
350 * @param url an absolute {@code URL} giving the base location of the audio |
355 * audio clip. |
351 * clip |
356 * @param name the location of the audio clip, relative to the |
352 * @param name the location of the audio clip, relative to the {@code url} |
357 * {@code url} argument. |
353 * argument |
358 * @return the audio clip at the specified URL. |
354 * @return the audio clip at the specified {@code URL} |
359 * @see java.applet.AudioClip |
355 * @see java.applet.AudioClip |
360 */ |
356 */ |
361 public AudioClip getAudioClip(URL url, String name) { |
357 public AudioClip getAudioClip(URL url, String name) { |
362 try { |
358 try { |
363 return getAudioClip(new URL(url, name)); |
359 return getAudioClip(new URL(url, name)); |
364 } catch (MalformedURLException e) { |
360 } catch (MalformedURLException e) { |
365 return null; |
361 return null; |
366 } |
362 } |
367 } |
363 } |
368 |
364 |
369 /** |
365 /** |
370 * Returns information about this applet. An applet should override |
366 * Returns information about this applet. An applet should override this |
371 * this method to return a {@code String} containing information |
367 * method to return a {@code String} containing information about the |
372 * about the author, version, and copyright of the applet. |
368 * author, version, and copyright of the applet. |
373 * <p> |
369 * <p> |
374 * The implementation of this method provided by the |
370 * The implementation of this method provided by the {@code Applet} class |
375 * {@code Applet} class returns {@code null}. |
371 * returns {@code null}. |
376 * |
372 * |
377 * @return a string containing information about the author, version, and |
373 * @return a string containing information about the author, version, and |
378 * copyright of the applet. |
374 * copyright of the applet |
379 */ |
375 */ |
380 public String getAppletInfo() { |
376 public String getAppletInfo() { |
381 return null; |
377 return null; |
382 } |
378 } |
383 |
379 |
384 /** |
380 /** |
385 * Gets the locale of the applet. It allows the applet |
381 * Gets the locale of the applet. It allows the applet to maintain its own |
386 * to maintain its own locale separated from the locale |
382 * locale separated from the locale of the browser or appletviewer. |
387 * of the browser or appletviewer. |
383 * |
388 * |
384 * @return the locale of the applet; if no locale has been set, the default |
389 * @return the locale of the applet; if no locale has |
385 * locale is returned |
390 * been set, the default locale is returned. |
386 * @since 1.1 |
391 * @since 1.1 |
|
392 */ |
387 */ |
393 public Locale getLocale() { |
388 public Locale getLocale() { |
394 Locale locale = super.getLocale(); |
389 Locale locale = super.getLocale(); |
395 if (locale == null) { |
390 if (locale == null) { |
396 return Locale.getDefault(); |
391 return Locale.getDefault(); |
397 } |
392 } |
398 return locale; |
393 return locale; |
399 } |
394 } |
400 |
395 |
401 /** |
396 /** |
402 * Returns information about the parameters that are understood by |
397 * Returns information about the parameters that are understood by this |
403 * this applet. An applet should override this method to return an |
398 * applet. An applet should override this method to return an array of |
404 * array of {@code Strings} describing these parameters. |
399 * strings describing these parameters. |
405 * <p> |
400 * <p> |
406 * Each element of the array should be a set of three |
401 * Each element of the array should be a set of three strings containing the |
407 * {@code Strings} containing the name, the type, and a |
402 * name, the type, and a description. For example: |
408 * description. For example: |
|
409 * <blockquote><pre> |
403 * <blockquote><pre> |
410 * String pinfo[][] = { |
404 * String pinfo[][] = { |
411 * {"fps", "1-10", "frames per second"}, |
405 * {"fps", "1-10", "frames per second"}, |
412 * {"repeat", "boolean", "repeat image loop"}, |
406 * {"repeat", "boolean", "repeat image loop"}, |
413 * {"imgs", "url", "images directory"} |
407 * {"imgs", "url", "images directory"} |
414 * }; |
408 * }; |
415 * </pre></blockquote> |
409 * </pre></blockquote> |
416 * <p> |
410 * <p> |
417 * The implementation of this method provided by the |
411 * The implementation of this method provided by the {@code Applet} class |
418 * {@code Applet} class returns {@code null}. |
412 * returns {@code null}. |
419 * |
413 * |
420 * @return an array describing the parameters this applet looks for. |
414 * @return an array describing the parameters this applet looks for |
421 */ |
415 */ |
422 public String[][] getParameterInfo() { |
416 public String[][] getParameterInfo() { |
423 return null; |
417 return null; |
424 } |
418 } |
425 |
419 |
426 /** |
420 /** |
427 * Plays the audio clip at the specified absolute URL. Nothing |
421 * Plays the audio clip at the specified absolute {@code URL}. Nothing |
428 * happens if the audio clip cannot be found. |
422 * happens if the audio clip cannot be found. |
429 * |
423 * |
430 * @param url an absolute URL giving the location of the audio clip. |
424 * @param url an absolute {@code URL} giving the location of the audio clip |
431 */ |
425 */ |
432 public void play(URL url) { |
426 public void play(URL url) { |
433 AudioClip clip = getAudioClip(url); |
427 AudioClip clip = getAudioClip(url); |
434 if (clip != null) { |
428 if (clip != null) { |
435 clip.play(); |
429 clip.play(); |
436 } |
430 } |
437 } |
431 } |
438 |
432 |
439 /** |
433 /** |
440 * Plays the audio clip given the URL and a specifier that is |
434 * Plays the audio clip given the {@code URL} and a specifier that is |
441 * relative to it. Nothing happens if the audio clip cannot be found. |
435 * relative to it. Nothing happens if the audio clip cannot be found. |
442 * |
436 * |
443 * @param url an absolute URL giving the base location of the |
437 * @param url an absolute {@code URL} giving the base location of the audio |
444 * audio clip. |
438 * clip |
445 * @param name the location of the audio clip, relative to the |
439 * @param name the location of the audio clip, relative to the {@code url} |
446 * {@code url} argument. |
440 * argument |
447 */ |
441 */ |
448 public void play(URL url, String name) { |
442 public void play(URL url, String name) { |
449 AudioClip clip = getAudioClip(url, name); |
443 AudioClip clip = getAudioClip(url, name); |
450 if (clip != null) { |
444 if (clip != null) { |
451 clip.play(); |
445 clip.play(); |
452 } |
446 } |
453 } |
447 } |
454 |
448 |
455 /** |
449 /** |
456 * Called by the browser or applet viewer to inform |
450 * Called by the browser or applet viewer to inform this applet that it has |
457 * this applet that it has been loaded into the system. It is always |
451 * been loaded into the system. It is always called before the first time |
458 * called before the first time that the {@code start} method is |
452 * that the {@code start} method is called. |
459 * called. |
453 * <p> |
460 * <p> |
454 * A subclass of {@code Applet} should override this method if it has |
461 * A subclass of {@code Applet} should override this method if |
455 * initialization to perform. For example, an applet with threads would use |
462 * it has initialization to perform. For example, an applet with |
456 * the {@code init} method to create the threads and the {@code destroy} |
463 * threads would use the {@code init} method to create the |
457 * method to kill them. |
|
458 * <p> |
|
459 * The implementation of this method provided by the {@code Applet} class |
|
460 * does nothing. |
|
461 * |
|
462 * @see java.applet.Applet#destroy() |
|
463 * @see java.applet.Applet#start() |
|
464 * @see java.applet.Applet#stop() |
|
465 */ |
|
466 public void init() { |
|
467 } |
|
468 |
|
469 /** |
|
470 * Called by the browser or applet viewer to inform this applet that it |
|
471 * should start its execution. It is called after the {@code init} method |
|
472 * and each time the applet is revisited in a Web page. |
|
473 * <p> |
|
474 * A subclass of {@code Applet} should override this method if it has any |
|
475 * operation that it wants to perform each time the Web page containing it |
|
476 * is visited. For example, an applet with animation might want to use the |
|
477 * {@code start} method to resume animation, and the {@code stop} method to |
|
478 * suspend the animation. |
|
479 * <p> |
|
480 * Note: some methods, such as {@code getLocationOnScreen}, can only provide |
|
481 * meaningful results if the applet is showing. Because {@code isShowing} |
|
482 * returns {@code false} when the applet's {@code start} is first called, |
|
483 * methods requiring {@code isShowing} to return {@code true} should be |
|
484 * called from a {@code ComponentListener}. |
|
485 * <p> |
|
486 * The implementation of this method provided by the {@code Applet} class |
|
487 * does nothing. |
|
488 * |
|
489 * @see java.applet.Applet#destroy() |
|
490 * @see java.applet.Applet#init() |
|
491 * @see java.applet.Applet#stop() |
|
492 * @see java.awt.Component#isShowing() |
|
493 * @see java.awt.event.ComponentListener#componentShown(ComponentEvent) |
|
494 */ |
|
495 public void start() { |
|
496 } |
|
497 |
|
498 /** |
|
499 * Called by the browser or applet viewer to inform this applet that it |
|
500 * should stop its execution. It is called when the Web page that contains |
|
501 * this applet has been replaced by another page, and also just before the |
|
502 * applet is to be destroyed. |
|
503 * <p> |
|
504 * A subclass of {@code Applet} should override this method if it has any |
|
505 * operation that it wants to perform each time the Web page containing it |
|
506 * is no longer visible. For example, an applet with animation might want to |
|
507 * use the {@code start} method to resume animation, and the {@code stop} |
|
508 * method to suspend the animation. |
|
509 * <p> |
|
510 * The implementation of this method provided by the {@code Applet} class |
|
511 * does nothing. |
|
512 * |
|
513 * @see java.applet.Applet#destroy() |
|
514 * @see java.applet.Applet#init() |
|
515 */ |
|
516 public void stop() { |
|
517 } |
|
518 |
|
519 /** |
|
520 * Called by the browser or applet viewer to inform this applet that it is |
|
521 * being reclaimed and that it should destroy any resources that it has |
|
522 * allocated. The {@code stop} method will always be called before |
|
523 * {@code destroy}. |
|
524 * <p> |
|
525 * A subclass of {@code Applet} should override this method if it has any |
|
526 * operation that it wants to perform before it is destroyed. For example, |
|
527 * an applet with threads would use the {@code init} method to create the |
464 * threads and the {@code destroy} method to kill them. |
528 * threads and the {@code destroy} method to kill them. |
465 * <p> |
529 * <p> |
466 * The implementation of this method provided by the |
530 * The implementation of this method provided by the {@code Applet} class |
467 * {@code Applet} class does nothing. |
531 * does nothing. |
468 * |
532 * |
469 * @see java.applet.Applet#destroy() |
533 * @see java.applet.Applet#init() |
470 * @see java.applet.Applet#start() |
534 * @see java.applet.Applet#start() |
471 * @see java.applet.Applet#stop() |
535 * @see java.applet.Applet#stop() |
472 */ |
|
473 public void init() { |
|
474 } |
|
475 |
|
476 /** |
|
477 * Called by the browser or applet viewer to inform |
|
478 * this applet that it should start its execution. It is called after |
|
479 * the {@code init} method and each time the applet is revisited |
|
480 * in a Web page. |
|
481 * <p> |
|
482 * A subclass of {@code Applet} should override this method if |
|
483 * it has any operation that it wants to perform each time the Web |
|
484 * page containing it is visited. For example, an applet with |
|
485 * animation might want to use the {@code start} method to |
|
486 * resume animation, and the {@code stop} method to suspend the |
|
487 * animation. |
|
488 * <p> |
|
489 * Note: some methods, such as {@code getLocationOnScreen}, can only |
|
490 * provide meaningful results if the applet is showing. Because |
|
491 * {@code isShowing} returns {@code false} when the applet's |
|
492 * {@code start} is first called, methods requiring |
|
493 * {@code isShowing} to return {@code true} should be called from |
|
494 * a {@code ComponentListener}. |
|
495 * <p> |
|
496 * The implementation of this method provided by the |
|
497 * {@code Applet} class does nothing. |
|
498 * |
|
499 * @see java.applet.Applet#destroy() |
|
500 * @see java.applet.Applet#init() |
|
501 * @see java.applet.Applet#stop() |
|
502 * @see java.awt.Component#isShowing() |
|
503 * @see java.awt.event.ComponentListener#componentShown(java.awt.event.ComponentEvent) |
|
504 */ |
|
505 public void start() { |
|
506 } |
|
507 |
|
508 /** |
|
509 * Called by the browser or applet viewer to inform |
|
510 * this applet that it should stop its execution. It is called when |
|
511 * the Web page that contains this applet has been replaced by |
|
512 * another page, and also just before the applet is to be destroyed. |
|
513 * <p> |
|
514 * A subclass of {@code Applet} should override this method if |
|
515 * it has any operation that it wants to perform each time the Web |
|
516 * page containing it is no longer visible. For example, an applet |
|
517 * with animation might want to use the {@code start} method to |
|
518 * resume animation, and the {@code stop} method to suspend the |
|
519 * animation. |
|
520 * <p> |
|
521 * The implementation of this method provided by the |
|
522 * {@code Applet} class does nothing. |
|
523 * |
|
524 * @see java.applet.Applet#destroy() |
|
525 * @see java.applet.Applet#init() |
|
526 */ |
|
527 public void stop() { |
|
528 } |
|
529 |
|
530 /** |
|
531 * Called by the browser or applet viewer to inform |
|
532 * this applet that it is being reclaimed and that it should destroy |
|
533 * any resources that it has allocated. The {@code stop} method |
|
534 * will always be called before {@code destroy}. |
|
535 * <p> |
|
536 * A subclass of {@code Applet} should override this method if |
|
537 * it has any operation that it wants to perform before it is |
|
538 * destroyed. For example, an applet with threads would use the |
|
539 * {@code init} method to create the threads and the |
|
540 * {@code destroy} method to kill them. |
|
541 * <p> |
|
542 * The implementation of this method provided by the |
|
543 * {@code Applet} class does nothing. |
|
544 * |
|
545 * @see java.applet.Applet#init() |
|
546 * @see java.applet.Applet#start() |
|
547 * @see java.applet.Applet#stop() |
|
548 */ |
536 */ |
549 public void destroy() { |
537 public void destroy() { |
550 } |
538 } |
551 |
539 |
552 // |
540 // |
553 // Accessibility support |
541 // Accessibility support |
554 // |
542 // |
555 |
543 |
|
544 /** |
|
545 * The accessible context associated with this {@code Applet}. |
|
546 */ |
556 AccessibleContext accessibleContext = null; |
547 AccessibleContext accessibleContext = null; |
557 |
548 |
558 /** |
549 /** |
559 * Gets the AccessibleContext associated with this Applet. |
550 * Gets the {@code AccessibleContext} associated with this {@code Applet}. |
560 * For applets, the AccessibleContext takes the form of an |
551 * For applets, the {@code AccessibleContext} takes the form of an |
561 * AccessibleApplet. |
552 * {@code AccessibleApplet}. A new {@code AccessibleApplet} instance is |
562 * A new AccessibleApplet instance is created if necessary. |
553 * created if necessary. |
563 * |
554 * |
564 * @return an AccessibleApplet that serves as the |
555 * @return an {@code AccessibleApplet} that serves as the |
565 * AccessibleContext of this Applet |
556 * {@code AccessibleContext} of this {@code Applet} |
566 * @since 1.3 |
557 * @since 1.3 |
567 */ |
558 */ |
568 public AccessibleContext getAccessibleContext() { |
559 public AccessibleContext getAccessibleContext() { |
569 if (accessibleContext == null) { |
560 if (accessibleContext == null) { |
570 accessibleContext = new AccessibleApplet(); |
561 accessibleContext = new AccessibleApplet(); |
571 } |
562 } |
572 return accessibleContext; |
563 return accessibleContext; |
573 } |
564 } |
574 |
565 |
575 /** |
566 /** |
576 * This class implements accessibility support for the |
567 * This class implements accessibility support for the {@code Applet} class. |
577 * {@code Applet} class. It provides an implementation of the |
568 * It provides an implementation of the Java Accessibility API appropriate |
578 * Java Accessibility API appropriate to applet user-interface elements. |
569 * to applet user-interface elements. |
|
570 * |
579 * @since 1.3 |
571 * @since 1.3 |
580 */ |
572 */ |
581 protected class AccessibleApplet extends AccessibleAWTPanel { |
573 protected class AccessibleApplet extends AccessibleAWTPanel { |
582 |
574 |
|
575 /** |
|
576 * Use serialVersionUID from JDK 1.3 for interoperability. |
|
577 */ |
583 private static final long serialVersionUID = 8127374778187708896L; |
578 private static final long serialVersionUID = 8127374778187708896L; |
584 |
579 |
585 /** |
580 /** |
586 * Get the role of this object. |
581 * Get the role of this object. |
587 * |
582 * |
588 * @return an instance of AccessibleRole describing the role of the |
583 * @return an instance of {@code AccessibleRole} describing the role of |
589 * object |
584 * the object |
590 */ |
585 */ |
591 public AccessibleRole getAccessibleRole() { |
586 public AccessibleRole getAccessibleRole() { |
592 return AccessibleRole.FRAME; |
587 return AccessibleRole.FRAME; |
593 } |
588 } |
594 |
589 |
595 /** |
590 /** |
596 * Get the state of this object. |
591 * Get the state of this object. |
597 * |
592 * |
598 * @return an instance of AccessibleStateSet containing the current |
593 * @return an instance of {@code AccessibleStateSet} containing the |
599 * state set of the object |
594 * current state set of the object |
600 * @see AccessibleState |
595 * @see AccessibleState |
601 */ |
596 */ |
602 public AccessibleStateSet getAccessibleStateSet() { |
597 public AccessibleStateSet getAccessibleStateSet() { |
603 AccessibleStateSet states = super.getAccessibleStateSet(); |
598 AccessibleStateSet states = super.getAccessibleStateSet(); |
604 states.add(AccessibleState.ACTIVE); |
599 states.add(AccessibleState.ACTIVE); |
605 return states; |
600 return states; |
606 } |
601 } |
607 |
|
608 } |
602 } |
609 } |
603 } |