1. /*
  2. * @(#)AppletContext.java 1.24 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.applet;
  8. import java.awt.Image;
  9. import java.awt.Graphics;
  10. import java.awt.image.ColorModel;
  11. import java.net.URL;
  12. import java.util.Enumeration;
  13. /**
  14. * This interface corresponds to an applet's environment: the
  15. * document containing the applet and the other applets in the same
  16. * document.
  17. * <p>
  18. * The methods in this interface can be used by an applet to obtain
  19. * information about its environment.
  20. *
  21. * @author Arthur van Hoff
  22. * @version 1.24, 11/29/01
  23. * @since JDK1.0
  24. */
  25. public interface AppletContext {
  26. /**
  27. * Creates an audio clip.
  28. *
  29. * @param url an absolute URL giving the location of the audio clip.
  30. * @return the audio clip at the specified URL.
  31. */
  32. AudioClip getAudioClip(URL url);
  33. /**
  34. * Returns an <code>Image</code> object that can then be painted on
  35. * the screen. The <code>url</code> argument<code> </code>that is
  36. * passed as an argument must specify an absolute URL.
  37. * <p>
  38. * This method always returns immediately, whether or not the image
  39. * exists. When the applet attempts to draw the image on the screen,
  40. * the data will be loaded. The graphics primitives that draw the
  41. * image will incrementally paint on the screen.
  42. *
  43. * @param url an absolute URL giving the location of the image.
  44. * @return the image at the specified URL.
  45. * @see java.awt.Image
  46. */
  47. Image getImage(URL url);
  48. /**
  49. * Finds and returns the applet in the document represented by this
  50. * applet context with the given name. The name can be set in the
  51. * HTML tag by setting the <code>name</code> attribute.
  52. *
  53. * @param name an applet name.
  54. * @return the applet with the given name, or <code>null</code> if
  55. * not found.
  56. */
  57. Applet getApplet(String name);
  58. /**
  59. * Finds all the applets in the document represented by this applet
  60. * context.
  61. *
  62. * @return an enumeration of all applets in the document represented by
  63. * this applet context.
  64. */
  65. Enumeration getApplets();
  66. /**
  67. * Replaces the Web page currently being viewed with the given URL.
  68. * This method may be ignored by applet contexts that are not
  69. * browsers.
  70. *
  71. * @param url an absolute URL giving the location of the document.
  72. */
  73. void showDocument(URL url);
  74. /**
  75. * Requests that the browser or applet viewer show the Web page
  76. * indicated by the <code>url</code> argument. The
  77. * <code>target</code> argument indicates in which HTML frame the
  78. * document is to be displayed.
  79. * The target argument is interpreted as follows:
  80. * <p>
  81. * <center><table border="3">
  82. * <tr><td><code>"_self"</code> <td>Show in the window and frame that
  83. * contain the applet.</tr>
  84. * <tr><td><code>"_parent"</code><td>Show in the applet's parent frame. If
  85. * the applet's frame has no parent frame,
  86. * acts the same as "_self".</tr>
  87. * <tr><td><code>"_top"</code> <td>Show in the top-level frame of the applet's
  88. * window. If the applet's frame is the
  89. * top-level frame, acts the same as "_self".</tr>
  90. * <tr><td><code>"_blank"</code> <td>Show in a new, unnamed
  91. * top-level window.</tr>
  92. * <tr><td><i>name</i><td>Show in the frame or window named <i>name</i>. If
  93. * a target named <i>name</i> does not already exist, a
  94. * new top-level window with the specified name is created,
  95. * and the document is shown there.</tr>
  96. * </table> </center>
  97. * <p>
  98. * An applet viewer or browser is free to ignore <code>showDocument</code>.
  99. *
  100. * @param url an absolute URL giving the location of the document.
  101. * @param target a <code>String</code> indicating where to display
  102. * the page.
  103. */
  104. public void showDocument(URL url, String target);
  105. /**
  106. * Requests that the argument string be displayed in the
  107. * "status window". Many browsers and applet viewers
  108. * provide such a window, where the application can inform users of
  109. * its current state.
  110. *
  111. * @param status a string to display in the status window.
  112. */
  113. void showStatus(String status);
  114. }