TopBlend:
Here is the
first difference.
There are 34 differences.
is old.
is new.
javax.swing
Class JApplet
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
javax.swing.JApplet
-
All Implemented Interfaces:
-
Accessible
,
ImageObserver
,
MenuContainer
,
RootPaneContainer
,
Serializable
-
public class
JApplet
-
extends
Applet
-
implements
Accessible
,
RootPaneContainer
An extended version of java.applet.Applet that adds support for the JFC/Swing component architecture. You can find task-oriented documentation about using JApplet in The Java Tutorial, in the section
How to Make Applets
.
The JApplet class is slightly incompatible with java.applet.Applet. JApplet contains a JRootPane as
its
it's
only child. The
contentPane
should be the parent of any children of the JApplet.
As
This is different than java.applet.Applet, e.g. to add
a
convenience add and its variants, remove and setLayout have been overridden
child
to
forward to the contentPane as necessary. This means you can
an an java.applet.Applet you'd
write:
applet.add(child);
And
However using JApplet you need to add
the child
will
to the JApplet's contentPane instead:
applet.getContentPane().add(child);
The same is true for setting LayoutManagers, removing components, listing children, etc. All these methods should normally
be
added
sent
to the
contentPane.
contentPane() instead of the JApplet itself.
The
contentPane
contentPane()
will always be non-null. Attempting to set it to null will cause the JApplet to throw an exception. The default
contentPane
contentPane()
will have a BorderLayout manager set on it.
Refer to
RootPaneContainer
for details on adding, removing and setting the LayoutManager of a JApplet.
Please see the JRootPane documentation for a complete description of the contentPane, glassPane, and layeredPane properties.
For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the
JApplet key assignments
.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans
TM
has been added to the java.beans package. Please see
XMLEncoder
.
-
See Also:
-
RootPaneContainer
Nested Class Summary
|
protected class |
JApplet.AccessibleJApplet
This class implements accessibility support for the JApplet class. |
Nested classes inherited from class java.awt.
Component
|
Component.AccessibleAWTComponent
,
Component.BltBufferStrategy
,
Component.FlipBufferStrategy
|
Fields inherited from interface java.awt.image.
ImageObserver
|
ABORT
,
ALLBITS
,
ERROR
,
FRAMEBITS
,
HEIGHT
,
PROPERTIES
,
SOMEBITS
,
WIDTH
|
Constructor Summary
|
JApplet
()
Creates a swing applet instance. |
Methods inherited from class java.applet.
Applet
|
destroy
,
getAppletContext
,
getAppletInfo
,
getAudioClip
,
getAudioClip
,
getCodeBase
,
getDocumentBase
,
getImage
,
getImage
,
getLocale
,
getParameter
,
getParameterInfo
,
init
,
isActive
,
newAudioClip
,
play
,
play
,
resize
,
resize
,
setStub
,
showStatus
,
start
,
stop
|
Methods inherited from 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
,
transferFocusBackward
,
transferFocusDownCycle
,
validate
,
validateTree
|
Methods inherited from 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
,
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
,
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
,
transferFocusUpCycle
|
rootPane
protected JRootPane rootPane
-
See Also:
-
getRootPane()
,
setRootPane(javax.swing.JRootPane)
rootPaneCheckingEnabled
protected boolean rootPaneCheckingEnabled
-
If true then calls to add and setLayout will be forwarded to the contentPane. This is initially false, but is set to true when the JApplet is constructed.
-
See Also:
-
isRootPaneCheckingEnabled()
,
setRootPaneCheckingEnabled(boolean)
,
RootPaneContainer
accessibleContext
protected AccessibleContext accessibleContext
JApplet
public JApplet()
throws HeadlessException
-
Creates a swing applet instance.
This constructor sets the component's locale property to the value returned by JComponent.getDefaultLocale.
-
Throws:
-
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true.
-
See Also:
-
GraphicsEnvironment.isHeadless()
,
JComponent.getDefaultLocale()
createRootPane
protected JRootPane createRootPane()
-
Called by the constructor methods to create the default rootPane.
-
-
update
public void update(Graphics g)
-
Just calls paint(g). This method was overridden to prevent an unnecessary call to clear the background.
-
-
Overrides:
-
update
in class
Container
-
-
Parameters:
-
g - the specified Graphics window
-
See Also:
-
Component.update(Graphics)
setJMenuBar
public void setJMenuBar(JMenuBar menuBar)
-
Sets the menubar for this applet.
-
-
-
Parameters:
-
menuBar - the menubar being placed in the applet
-
See Also:
-
getJMenuBar()
getJMenuBar
public JMenuBar getJMenuBar()
-
Returns the menubar set on this applet.
-
-
-
See Also:
-
setJMenuBar(javax.swing.JMenuBar)
isRootPaneCheckingEnabled
protected boolean isRootPaneCheckingEnabled()
-
Returns whether calls to add and setLayout are forwarded to the contentPane.
-
-
-
Returns:
-
true if add and setLayout
are fowarded; false otherwise
should be checked
-
See Also:
-
addImpl(java.awt.Component, java.lang.Object, int)
,
setLayout(java.awt.LayoutManager)
,
setRootPaneCheckingEnabled(boolean)
,
RootPaneContainer
setRootPaneCheckingEnabled
protected void setRootPaneCheckingEnabled(boolean enabled)
-
Sets whether calls to add and setLayout are forwarded to the contentPane.
If true then calls to add() and setLayout() will cause an exception to be thrown.
-
-
-
Parameters:
-
enabled - true if add and setLayout are forwarded, false if they should operate directly on the JApplet.
-
See Also:
-
addImpl(java.awt.Component, java.lang.Object, int)
,
setLayout(java.awt.LayoutManager)
,
isRootPaneCheckingEnabled()
,
RootPaneContainer
addImpl
protected void addImpl(Component comp,
Object constraints,
int index)
-
Adds the specified child Component. This method is overridden to conditionally forwad calls to the contentPane. By default, children are added to the contentPane instead of the frame, refer to
RootPaneContainer
for details.
By default, children may not be added directly to a this component, they must be added to its contentPane instead. For example:
thiComponent.getContentPane().add(child)
An attempt to add to directly to this component will cause an runtime exception to be thrown. Subclasses can disable this behavior.
-
-
Overrides:
-
addImpl
in class
Container
-
-
Parameters:
-
comp - the component to be
enhanced
added
-
constraints - the constraints to be respected
constraints - an object expressing layout constraints for this component
-
index - the index
index - the position in the container's list at which to insert the component, where -1 means append to the end
-
Throws:
-
IllegalArgumentException
Error
- if index is invalid
-
IllegalArgumentException
- if adding the container's parent to itself
-
IllegalArgumentException
- if adding a window to a container
- if called with rootPaneChecking true
-
See Also:
-
setRootPaneCheckingEnabled(boolean)
,
RootPaneContainer
remove
public void remove(Component comp)
-
Removes the specified component from the container. If comp is not the rootPane, this will forward the call to the contentPane. This will do nothing if comp is not a child of the JFrame or contentPane.
Removes the specified component from this container.
-
-
Overrides:
-
remove
in class
Container
-
-
Parameters:
-
comp - the component to be removed
-
Throws:
-
NullPointerException
- if comp is null
-
See Also:
-
Container.add(java.awt.Component)
,
RootPaneContainer
setLayout
public void setLayout(LayoutManager manager)
-
Sets the LayoutManager. Overridden to conditionally forward the call to the contentPane. Refer to
RootPaneContainer
for more information.
By default the layout of this component may not be set, the layout of its contentPane should be set instead. For example:
thisComponent.getContentPane().setLayout(new GridLayout(1, 2))
An attempt to set the layout of this component will cause an runtime exception to be thrown. Subclasses can disable this behavior.
-
-
Overrides:
-
setLayout
in class
Container
-
-
Parameters:
-
manager - the
LayoutManager
specified layout manager
-
Throws:
-
Error
- if called with rootPaneChecking true
-
See Also:
-
setRootPaneCheckingEnabled(boolean)
,
RootPaneContainer
getRootPane
public JRootPane getRootPane()
-
Returns the rootPane object for this applet.
-
-
Specified by:
-
getRootPane
in interface
RootPaneContainer
-
-
Returns:
-
this components single JRootPane child.
-
See Also:
-
setRootPane(javax.swing.JRootPane)
,
RootPaneContainer.getRootPane()
setRootPane
protected void setRootPane(JRootPane root)
-
Sets the rootPane property. This method is called by the constructor.
-
-
-
Parameters:
-
root - the rootPane object for this applet
-
See Also:
-
getRootPane()
getContentPane
public Container getContentPane()
-
Returns the contentPane object for this applet.
-
-
Specified by:
-
getContentPane
in interface
RootPaneContainer
-
-
Returns:
-
the value of the contentPane property.
-
See Also:
-
setContentPane(java.awt.Container)
,
RootPaneContainer.getContentPane()
setContentPane
public void setContentPane(Container contentPane)
-
Sets the contentPane property. This method is called by the constructor.
-
-
Specified by:
-
setContentPane
in interface
RootPaneContainer
-
-
Parameters:
-
contentPane - the contentPane object for this applet
-
Throws:
-
IllegalComponentStateException
- (a runtime exception) if the content pane parameter is null
-
See Also:
-
getContentPane()
,
RootPaneContainer.setContentPane(java.awt.Container)
getLayeredPane
public JLayeredPane getLayeredPane()
-
Returns the layeredPane object for this applet.
-
-
Specified by:
-
getLayeredPane
in interface
RootPaneContainer
-
-
Returns:
-
the value of the layeredPane property.
-
Throws:
-
IllegalComponentStateException
- (a runtime exception) if the layered pane parameter is null
-
See Also:
-
setLayeredPane(javax.swing.JLayeredPane)
,
RootPaneContainer.getLayeredPane()
setLayeredPane
public void setLayeredPane(JLayeredPane layeredPane)
-
Sets the layeredPane property. This method is called by the constructor.
-
-
Specified by:
-
setLayeredPane
in interface
RootPaneContainer
-
-
Parameters:
-
layeredPane - the layeredPane object for this applet
-
See Also:
-
getLayeredPane()
,
RootPaneContainer.setLayeredPane(javax.swing.JLayeredPane)
getGlassPane
public Component getGlassPane()
-
Returns the glassPane object for this applet.
-
-
Specified by:
-
getGlassPane
in interface
RootPaneContainer
-
-
Returns:
-
the value of the glassPane property.
-
See Also:
-
setGlassPane(java.awt.Component)
,
RootPaneContainer.getGlassPane()
setGlassPane
public void setGlassPane(Component glassPane)
-
Sets the glassPane property. This method is called by the constructor.
-
-
Specified by:
-
setGlassPane
in interface
RootPaneContainer
-
-
Parameters:
-
glassPane - the glassPane object for this applet
-
See Also:
-
getGlassPane()
,
RootPaneContainer.setGlassPane(java.awt.Component)
paramString
protected String paramString()
-
Returns a string representation of this JApplet. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
-
-
Overrides:
-
paramString
in class
Container
-
-
Returns:
-
a string representation of this JApplet.
getAccessibleContext
public AccessibleContext getAccessibleContext()
-
Gets the AccessibleContext associated with this JApplet. For JApplets, the AccessibleContext takes the form of an AccessibleJApplet. A new AccessibleJApplet instance is created if necessary.
-
-
Specified by:
-
getAccessibleContext
in interface
Accessible
-
Overrides:
-
getAccessibleContext
in class
Applet
-
-
Returns:
-
an AccessibleJApplet that serves as the AccessibleContext of this JApplet