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