java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet
- 所有已实现的接口:
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
,RootPaneContainer
@Deprecated(since="9", forRemoval=true) @JavaBean(defaultProperty="JMenuBar", description="Swing\'s Applet subclass.") public class JApplet extends Applet implements Accessible, RootPaneContainer
Deprecated, for removal: This API element is subject to removal in a future version.
The Applet API is deprecated, no replacement.
一个扩展版本的
java.applet.Applet
,增加了对JFC/Swing组件架构的支持。您可以在The Java Tutorial的How to Make Applets部分找到关于如何使用JApplet
的面向任务的文档。
JApplet
类与java.applet.Applet
略有不兼容。 JApplet
包含一个JRootPane
作为其唯一子级。 contentPane
应该是JApplet
的任何子级的父级。 作为一种便利,此类的add
、remove
和setLayout
方法被覆盖,以便它们将调用委托给ContentPane
的相应方法。 例如,您可以按如下方式向applet添加子组件:
applet.add(child);然后子组件将被添加到
contentPane
。 contentPane
将始终为非null
。 尝试将其设置为null
将导致JApplet
抛出异常。 默认的contentPane
将具有BorderLayout
管理器设置在其上。 有关如何向JApplet
添加、移除和设置LayoutManager
的详细信息,请参阅RootPaneContainer
。
请参阅JRootPane
文档,了解contentPane
、glassPane
和layeredPane
属性的完整描述。
警告: Swing不是线程安全的。有关更多信息,请参阅Swing的线程策略。
警告: 此类的序列化对象将不兼容未来的Swing版本。当前的序列化支持适用于短期存储或在运行相同版本Swing的应用程序之间的RMI。 从1.4开始,已将所有JavaBeans的长期存储支持添加到java.beans
包中。 请参阅XMLEncoder
。
- 自:
- 1.2
- 参见:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
已弃用,将被移除: 此API元素可能在将来的版本中被移除。该类为JApplet
类实现了辅助功能支持。Nested classes/interfaces declared in class java.applet.Applet
Applet.AccessibleApplet
Nested classes/interfaces declared in class java.awt.Panel
Panel.AccessibleAWTPanel
Nested classes/interfaces declared in class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces declared in class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Modifier and TypeFieldDescriptionprotected AccessibleContext
已弃用,将被移除: 此API元素可能在将来的版本中被移除。与此JApplet
关联的AccessibleContext
protected JRootPane
已弃用,将被移除: 此API元素可能在将来的版本中被移除。管理contentPane
的JRootPane
实例。protected boolean
已弃用,将被移除: 此API元素可能在将来的版本中被移除。如果为true,则对add
和setLayout
的调用将被转发到contentPane
。Fields declared in class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields declared in interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
已弃用,将被移除: 此API元素可能在将来的版本中被移除。添加指定的子Component
。protected JRootPane
已弃用,将被移除: 此API元素可能在将来的版本中被移除。由构造方法调用以创建默认的rootPane。已弃用,将被移除: 此API元素可能在将来的版本中被移除。获取与此JApplet关联的AccessibleContext。已弃用,将被移除: 此API元素可能在将来的版本中被移除。返回此applet的contentPane对象。已弃用,将被移除: 此API元素可能在将来的版本中被移除。返回此applet的glassPane对象。已弃用,将被移除: 此API元素可能在将来的版本中被移除。为此组件创建一个图形上下文。已弃用,将被移除: 此API元素可能在将来的版本中被移除。返回设置在此applet上的菜单栏。已弃用,将被移除: 此API元素可能在将来的版本中被移除。返回此applet的layeredPane对象。已弃用,将被移除: 此API元素可能在将来的版本中被移除。返回此applet的rootPane对象。已弃用,将被移除: 此API元素可能在将来的版本中被移除。获取transferHandler
属性。protected boolean
已弃用,将被移除: 此API元素可能在将来的版本中被移除。返回是否将add
和setLayout
的调用转发到contentPane
。protected String
已弃用,将被移除: 此API元素可能在将来的版本中被移除。返回此JApplet的字符串表示形式。void
已弃用,将被移除: 此API元素可能在将来的版本中被移除。从容器中移除指定的组件。void
repaint
(long time, int x, int y, int width, int height) 已弃用,将被移除: 此API元素可能在将来的版本中被移除。在time
毫秒内重绘此组件的指定矩形。void
setContentPane
(Container contentPane) 已弃用,将被移除: 此API元素可能在将来的版本中被移除。设置contentPane
属性。void
setGlassPane
(Component glassPane) 已弃用,将被移除: 此API元素可能在将来的版本中被移除。设置glassPane
属性。void
setJMenuBar
(JMenuBar menuBar) 已弃用,将被移除: 此API元素可能在将来的版本中被移除。设置此applet的菜单栏。void
setLayeredPane
(JLayeredPane layeredPane) 已弃用,将被移除: 此API元素可能在将来的版本中被移除。设置layeredPane
属性。void
setLayout
(LayoutManager manager) 已弃用,将被移除: 此API元素可能在将来的版本中被移除。设置LayoutManager
。protected void
setRootPane
(JRootPane root) 已弃用,将被移除: 此API元素可能在将来的版本中被移除。设置rootPane
属性。protected void
setRootPaneCheckingEnabled
(boolean enabled) 已弃用,将被移除: 此API元素可能在将来的版本中被移除。设置是否将add
和setLayout
的调用转发到contentPane
。void
setTransferHandler
(TransferHandler newHandler) 已弃用,将被移除: 此API元素可能在将来的版本中被移除。设置transferHandler
属性,这是支持将数据传输到此组件的机制。void
已弃用,将被移除: 此API元素可能在将来的版本中被移除。仅调用paint(g)
。Methods declared in class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
Methods declared in class java.awt.Container
add, add, add, add, add, addContainerListener, 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, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
Methods declared in class java.awt.Component
action, 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, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, 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, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setMixingCutoutShape, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
rootPane
Deprecated, for removal: This API element is subject to removal in a future version.管理contentPane
的JRootPane
实例。- 参见:
-
rootPaneCheckingEnabled
protected boolean rootPaneCheckingEnabledDeprecated, for removal: This API element is subject to removal in a future version.如果为true,则对add
和setLayout
的调用将被转发到contentPane
。 初始值为false,但在构造JApplet
时设置为true。- 参见:
-
accessibleContext
Deprecated, for removal: This API element is subject to removal in a future version.与此JApplet
关联的AccessibleContext
-
-
Constructor Details
-
JApplet
Deprecated, for removal: This API element is subject to removal in a future version.创建一个Swing applet实例。此构造方法将组件的locale属性设置为
JComponent.getDefaultLocale
返回的值。- 抛出:
-
HeadlessException
- 如果GraphicsEnvironment.isHeadless()
返回true。 - 参见:
-
-
Method Details
-
createRootPane
Deprecated, for removal: This API element is subject to removal in a future version.由构造方法调用以创建默认的rootPane。- 返回:
-
一个新的
JRootPane
-
setTransferHandler
@BeanProperty(hidden=true, description="Mechanism for transfer of data into the component") public void setTransferHandler(TransferHandler newHandler) Deprecated, for removal: This API element is subject to removal in a future version.设置transferHandler
属性,这是一种支持将数据传输到此组件的机制。如果组件不支持数据传输操作,请使用null
。如果系统属性
suppressSwingDropSupport
为false
(默认值),并且此组件上的当前放置目标要么是null
,要么不是用户设置的放置目标,则此方法将按以下方式更改放置目标:如果newHandler
为null
,它将清除放置目标。如果不为null
,它将安装一个新的DropTarget
。注意:当与
JApplet
一起使用时,TransferHandler
仅提供数据导入功能,因为数据导出相关方法当前是针对JComponent
类型的。更多信息请参阅 如何使用拖放和数据传输,这是 The Java Tutorial 中的一个章节。
- 参数:
-
newHandler
- 新的TransferHandler
- 自版本:
- 1.6
- 另请参阅:
-
getTransferHandler
Deprecated, for removal: This API element is subject to removal in a future version.获取transferHandler
属性。- 返回:
-
transferHandler
属性的值 - 自版本:
- 1.6
- 另请参阅:
-
update
Deprecated, for removal: This API element is subject to removal in a future version.只调用paint(g)
。重写此方法是为了防止不必要地清除背景。 -
setJMenuBar
@BeanProperty(bound=false, hidden=true, description="The menubar for accessing pulldown menus from this applet.") public void setJMenuBar(JMenuBar menuBar) Deprecated, for removal: This API element is subject to removal in a future version.为此 applet 设置菜单栏。- 参数:
-
menuBar
- 要放置在 applet 中的菜单栏 - 另请参阅:
-
getJMenuBar
Deprecated, for removal: This API element is subject to removal in a future version.返回在此 applet 上设置的菜单栏。- 返回:
- 在此 applet 上设置的菜单栏
- 另请参阅:
-
isRootPaneCheckingEnabled
protected boolean isRootPaneCheckingEnabled()Deprecated, for removal: This API element is subject to removal in a future version.返回是否将add
和setLayout
的调用转发到contentPane
。- 返回:
-
如果将
add
和setLayout
的调用转发,则返回 true;否则返回 false - 另请参阅:
-
setRootPaneCheckingEnabled
@BeanProperty(hidden=true, description="Whether the add and setLayout methods are forwarded") protected void setRootPaneCheckingEnabled(boolean enabled) Deprecated, for removal: This API element is subject to removal in a future version.设置是否将add
和setLayout
的调用转发到contentPane
。- 参数:
-
enabled
- 如果将add
和setLayout
的调用转发,则为 true;如果应直接在JApplet
上操作,则为 false。 - 另请参阅:
-
addImpl
Deprecated, for removal: This API element is subject to removal in a future version.添加指定的子Component
。重写此方法以有条件地将调用转发到contentPane
。默认情况下,子组件将添加到contentPane
而不是框架,请参考RootPaneContainer
以获取详细信息。- 覆盖:
-
addImpl
在类Container
中 - 参数:
-
comp
- 要增强的组件 -
constraints
- 要遵守的约束 -
index
- 索引 - 抛出:
-
IllegalArgumentException
- 如果index
无效 -
IllegalArgumentException
- 如果将容器的父级添加到自身 -
IllegalArgumentException
- 如果将窗口添加到容器 - 另请参阅:
-
remove
Deprecated, for removal: This API element is subject to removal in a future version.从容器中移除指定的组件。如果comp
不是rootPane
,则会将此调用转发到contentPane
。如果comp
不是JFrame
或contentPane
的子级,则不会执行任何操作。- 覆盖:
-
remove
在类Container
中 - 参数:
-
comp
- 要移除的组件 - 抛出:
-
NullPointerException
- 如果comp
为 null - 另请参阅:
-
setLayout
Deprecated, for removal: This API element is subject to removal in a future version. -
getRootPane
@BeanProperty(bound=false, hidden=true, description="the RootPane object for this applet.") public JRootPane getRootPane()Deprecated, for removal: This API element is subject to removal in a future version.返回此 applet 的 rootPane 对象。- 指定者:
-
getRootPane
在接口RootPaneContainer
中 - 返回:
- 此组件的单个 JRootPane 子级。
- 另请参阅:
-
setRootPane
Deprecated, for removal: This API element is subject to removal in a future version.设置 rootPane 属性。此方法由构造函数调用。- 参数:
-
root
- 此 applet 的 rootPane 对象 - 另请参阅:
-
getContentPane
Deprecated, for removal: This API element is subject to removal in a future version.返回此 applet 的 contentPane 对象。- 指定者:
-
getContentPane
在接口RootPaneContainer
中 - 返回:
- contentPane 属性的值。
- 另请参阅:
-
setContentPane
@BeanProperty(bound=false, hidden=true, description="The client area of the applet where child components are normally inserted.") public void setContentPane(Container contentPane) Deprecated, for removal: This API element is subject to removal in a future version.设置 contentPane 属性。此方法由构造函数调用。- 指定由:
-
setContentPane
在接口RootPaneContainer
中 - 参数:
-
contentPane
- 该applet的contentPane对象 - 抛出:
-
IllegalComponentStateException
- 如果content pane参数为null(运行时异常) - 参见:
-
getLayeredPane
Deprecated, for removal: This API element is subject to removal in a future version.返回该applet的layeredPane对象。- 指定由:
-
getLayeredPane
在接口RootPaneContainer
中 - 返回:
- layeredPane属性的值。
- 抛出:
-
IllegalComponentStateException
- 如果layered pane参数为null(运行时异常) - 参见:
-
setLayeredPane
@BeanProperty(bound=false, hidden=true, description="The pane which holds the various applet layers.") public void setLayeredPane(JLayeredPane layeredPane) Deprecated, for removal: This API element is subject to removal in a future version.设置layeredPane属性。此方法由构造函数调用。- 指定由:
-
setLayeredPane
在接口RootPaneContainer
中 - 参数:
-
layeredPane
- 该applet的layeredPane对象 - 参见:
-
getGlassPane
Deprecated, for removal: This API element is subject to removal in a future version.返回该applet的glassPane对象。- 指定由:
-
getGlassPane
在接口RootPaneContainer
中 - 返回:
- glassPane属性的值。
- 参见:
-
setGlassPane
@BeanProperty(bound=false, hidden=true, description="A transparent pane used for menu rendering.") public void setGlassPane(Component glassPane) Deprecated, for removal: This API element is subject to removal in a future version.设置glassPane属性。此方法由构造函数调用。- 指定由:
-
setGlassPane
在接口RootPaneContainer
中 - 参数:
-
glassPane
- 该applet的glassPane对象 - 参见:
-
getGraphics
Deprecated, for removal: This API element is subject to removal in a future version.为此组件创建一个图形上下文。如果此组件当前不可显示,则此方法将返回null
。- 覆盖:
-
getGraphics
在类Component
中 - 返回:
-
该组件的图形上下文,如果没有则返回
null
- 自:
- 1.6
- 参见:
-
repaint
public void repaint(long time, int x, int y, int width, int height) Deprecated, for removal: This API element is subject to removal in a future version.在time
毫秒内重新绘制此组件的指定矩形。有关重绘如何处理的详细信息,请参阅RepaintManager
。 -
paramString
Deprecated, for removal: This API element is subject to removal in a future version.返回此JApplet的字符串表示形式。此方法仅用于调试目的,返回的字符串的内容和格式可能因实现而异。返回的字符串可能为空,但不能为null
。- 覆盖:
-
paramString
在类Container
中 - 返回:
- 此JApplet的字符串表示形式。
-
getAccessibleContext
Deprecated, for removal: This API element is subject to removal in a future version.获取与此JApplet关联的AccessibleContext。对于JApplets,AccessibleContext采用AccessibleJApplet的形式。如有必要,将创建一个新的AccessibleJApplet实例。- 指定由:
-
getAccessibleContext
在接口Accessible
中 - 覆盖:
-
getAccessibleContext
在类Applet
中 - 返回:
- 作为此JApplet的AccessibleContext的AccessibleJApplet
-