public class Applet extends Panel
Applet类必须是要嵌入到Web页面中或由Java Applet Viewer查看的任何小程序的Applet类。 Applet类提供了applet与其环境之间的标准接口。
| Modifier and Type | Class and Description |
|---|---|
protected class |
Applet.AccessibleApplet
这个类实现了可访问性支持
Applet类。
|
Panel.AccessibleAWTPanelContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
Applet()
构建一个新的Applet。
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
由浏览器或小程序查看器调用以通知此小程序它正在被回收,并且它应该销毁其分配的任何资源。
|
AccessibleContext |
getAccessibleContext()
获取与此Applet关联的AccessibleContext。
|
AppletContext |
getAppletContext()
确定这个小程序的上下文,这允许小程序查询并影响它运行的环境。
|
String |
getAppletInfo()
返回有关此小程序的信息。
|
AudioClip |
getAudioClip(URL url)
返回由
URL参数指定的
AudioClip对象。
|
AudioClip |
getAudioClip(URL url, String name)
返回
URL和
name参数指定的
AudioClip对象。
|
URL |
getCodeBase()
获取基本URL。
|
URL |
getDocumentBase()
获取嵌入此小程序的文档的URL。
|
Image |
getImage(URL url)
返回一个
Image对象,然后可以在屏幕上绘制。
|
Image |
getImage(URL url, String name)
返回一个
Image对象,然后可以在屏幕上绘制。
|
Locale |
getLocale()
获取小程序的区域设置。
|
String |
getParameter(String name)
返回HTML标签中命名参数的值。
|
String[][] |
getParameterInfo()
返回有关此applet可以理解的参数的信息。
|
void |
init()
由浏览器或小程序查看器调用以通知此小程序已将其加载到系统中。
|
boolean |
isActive()
确定此applet是否处于活动状态。
|
boolean |
isValidateRoot()
指示此容器是否为验证根。
|
static AudioClip |
newAudioClip(URL url)
从给定的URL获取音频剪辑。
|
void |
play(URL url)
以指定的绝对URL播放音频剪辑。
|
void |
play(URL url, String name)
播放给定URL的音频剪辑和与之相关的说明符。
|
void |
resize(Dimension d)
请求这个小程序调整大小。
|
void |
resize(int width, int height)
请求这个小程序调整大小。
|
void |
setStub(AppletStub stub)
设置这个小程序的存根。
|
void |
showStatus(String msg)
请求参数字符串显示在“状态窗口”中。
|
void |
start()
由浏览器或小程序查看器调用,通知该小程序应该开始执行。
|
void |
stop()
由浏览器或小程序查看器调用,通知该小程序应该停止其执行。
|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic Applet()
throws HeadlessException
注意:只有小程序完全构建后,小程序才能调用java.applet.Applet中的许多方法; applet应避免在java.applet.Applet中调用java.applet.Applet中的方法。
HeadlessException - 如果GraphicsEnvironment.isHeadless()返回true。
GraphicsEnvironment.isHeadless()
public final void setStub(AppletStub stub)
如果有一个安全管理器,它的checkPermission方法被调用与AWTPermission("setAppletStub")权限,如果存根已经设置。
stub - 新的存根。
SecurityException - 如果调用者不能设置存根
public boolean isActive()
start方法之前被标记为活动。
在它stop方法之前,它变得不活动。
public URL getDocumentBase()
http://www.oracle.com/technetwork/java/index.html
文件基础是:
http://www.oracle.com/technetwork/java/index.html
URL 。
getCodeBase()
public URL getCodeBase()
URL 。
getDocumentBase()
public String getParameter(String name)
<applet code="Clock" width=50 height=50> <param name=Color value="blue"> </applet>
那么一个电话getParameter("Color")返回值"blue" 。
name参数不区分大小写。
name - 参数名称。
null 。
public AppletContext getAppletContext()
小程序的这个环境代表包含小程序的文档。
public void resize(int width,
int height)
public boolean isValidateRoot()
Applet对象是验证根,因此,它们覆盖此方法以返回true 。
isValidateRoot在类别
Container
true
Container.isValidateRoot()
public void showStatus(String msg)
msg - 在状态窗口中显示的字符串。
public Image getImage(URL url)
Image对象,然后可以在屏幕上绘制。
作为参数传递的url必须指定绝对URL。
该方法始终立即返回,无论图像是否存在。 当该小程序尝试在屏幕上绘制图像时,将加载数据。 绘制图像的图形基元将逐渐在屏幕上绘制。
url - 给出图像位置的绝对URL。
Image
public Image getImage(URL url, String name)
Image对象,然后可以在屏幕上绘制。
url参数必须指定绝对URL。
name参数是一个相对于url参数的url 。
该方法始终立即返回,无论图像是否存在。 当该小程序尝试在屏幕上绘制图像时,将加载数据。 绘制图像的图形基元将逐渐在屏幕上绘制。
url - 给出图像基本位置的绝对URL。
name - 相对于
url参数的图像的位置。
Image
public static final AudioClip newAudioClip(URL url)
url - 指向音频剪辑
public AudioClip getAudioClip(URL url)
URL参数指定的AudioClip对象。
无论音频剪辑是否存在,此方法始终立即返回。 当该小程序尝试播放音频剪辑时,将加载数据。
url - 给出音频剪辑位置的绝对URL。
AudioClip
public AudioClip getAudioClip(URL url, String name)
URL和name参数指定的AudioClip对象。
无论音频剪辑是否存在,此方法始终立即返回。 当该小程序尝试播放音频剪辑时,将加载数据。
url - 给出音频剪辑的基本位置的绝对URL。
name - 相对于
url参数的音频剪辑的位置。
AudioClip
public String getAppletInfo()
String其中包含有关该小程序的作者,版本和版权的信息。
Applet类提供的这种方法的Applet返回null 。
public Locale getLocale()
getLocale在类别
Component
Component.setLocale(java.util.Locale)
public String[][] getParameterInfo()
Strings描述这些参数。
数组的每个元素应该是一组三个, Strings名称,类型和描述。 例如:
String pinfo[][] = {
{"fps", "1-10", "frames per second"},
{"repeat", "boolean", "repeat image loop"},
{"imgs", "url", "images directory"}
};
Applet类提供的这种方法的Applet返回null 。
public void play(URL url)
url - 给出音频剪辑位置的绝对URL。
public void play(URL url, String name)
url - 给出音频剪辑的基本位置的绝对URL。
name - 音频剪辑的位置,相对于
url参数。
public void init()
start方法。
Applet的子类如果具有要执行的初始化,则应该覆盖此方法。 例如,具有线程的小程序将使用init方法创建线程和destroy方法来杀死它们。
Applet类提供的这种方法的Applet什么都不做。
public void start()
init方法之后调用的,每次在网页中重新访问applet。
如果Applet的子类在每次访问包含该网页的任何操作时都应该覆盖此方法。 例如,具有动画的小程序可能想要使用start方法来恢复动画,以及stop方法来暂停动画。
注意:一些方法,如getLocationOnScreen ,只有在小程序显示时才能提供有意义的结果。 因为isShowing返回false当小程序的start是第一次调用,方法要求isShowing返回true应该从一个ComponentListener 。
Applet类提供的这种方法的Applet什么都不做。
public void stop()
Applet的子类应该覆盖此方法,如果它有任何操作,每次包含它的网页不再可见时,它执行。 例如,具有动画的小程序可能想使用start方法来恢复动画,而stop方法可能会暂停动画。
Applet类提供的这种方法的Applet什么都不做。
public void destroy()
stop方法将始终在destroy之前destroy 。
Applet的子类应该覆盖此方法,如果它有任何操作,它要在执行它被销毁之前执行。 例如,具有线程的小程序将使用init方法创建线程和destroy方法来杀死它们。
Applet类提供的这种方法的Applet什么都不做。
public AccessibleContext getAccessibleContext()
getAccessibleContext在界面
Accessible
getAccessibleContext在类别
Panel
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.