javax.swing
Class JLayeredPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JLayeredPane
All Implemented Interfaces:
Accessible, java.awt.image.ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
JDesktopPane

public class JLayeredPane
extends JComponent
implements Accessible

Unsafe:

See Also:
Serialized Form

Field Summary
private  Hashtable componentToLayer
           
static Integer DEFAULT_LAYER
          Suppressed: Convenience object defining the Default layer.
static Integer DRAG_LAYER
          Suppressed: Convenience object defining the Drag layer.
static Integer FRAME_CONTENT_LAYER
          Suppressed: Convenience object defining the Frame Content layer.
static String LAYER_PROPERTY
          Suppressed: Bound property
static Integer MODAL_LAYER
          Suppressed: Convenience object defining the Modal layer.
private  boolean optimizedDrawingPossible
           
static Integer PALETTE_LAYER
          Suppressed: Convenience object defining the Palette layer.
static Integer POPUP_LAYER
          Suppressed: Convenience object defining the Popup layer.
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, listenerList, paintingChild, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
JLayeredPane()
          Suppressed: Create a new JLayeredPane
 
Method Summary
protected  void addImpl(Component comp, Object constraints, int index)
          Adds the specified component to this container at the specified index.
 AccessibleContext getAccessibleContext()
          Suppressed: Gets the AccessibleContext associated with this JLayeredPane.
 int getComponentCountInLayer(int layer)
          Suppressed: Returns the number of children currently in the specified layer.
 Component[] getComponentsInLayer(int layer)
          Suppressed: Returns an array of the components in the specified layer.
protected  Hashtable getComponentToLayer()
          Returns the hashtable that maps components to layers.
 int getIndexOf(Component c)
          Suppressed: Returns the index of the specified Component.
 int getLayer(Component c)
          Suppressed: Returns the layer attribute for the specified Component.
static int getLayer(JComponent c)
          Suppressed: Gets the layer property for a JComponent, it does not cause any side effects like setLayer().
static JLayeredPane getLayeredPaneAbove(Component c)
          Suppressed: Convenience method that returns the first JLayeredPane which contains the specified component.
protected  Integer getObjectForLayer(int layer)
          Returns the Integer object associated with a specified layer.
 int getPosition(Component c)
          Suppressed: Get the relative position of the component within its layer.
 int highestLayer()
          Suppressed: Returns the highest layer value from all current children.
protected  int insertIndexForLayer(int layer, int position)
          Primitive method that determines the proper location to insert a new child based on layer and position requests.
 boolean isOptimizedDrawingEnabled()
          Suppressed: Returns false if components in the pane can overlap, which makes optimized drawing impossible.
 int lowestLayer()
          Suppressed: Returns the lowest layer value from all current children.
 void moveToBack(Component c)
          Suppressed: Moves the component to the bottom of the components in its current layer (position -1).
 void moveToFront(Component c)
          Suppressed: Moves the component to the top of the components in its current layer (position 0).
 void paint(Graphics g)
          Suppressed: Paints this JLayeredPane within the specified graphics context.
protected  String paramString()
          Returns a string representation of this JLayeredPane.
static void putLayer(JComponent c, int layer)
          Suppressed: Sets the layer property on a JComponent.
 void remove(int index)
          Suppressed: Remove the indexed component from this pane.
 void setLayer(Component c, int layer)
          Suppressed: Sets the layer attribute on the specified component, making it the bottommost component in that layer.
 void setLayer(Component c, int layer, int position)
          Suppressed: Sets the layer attribute for the specified component and also sets its position within that layer.
 void setPosition(Component c, int position)
          Suppressed: Moves the component to position within its current layer, where 0 is the topmost position within the layer and -1 is the bottommost position.
private  void validateOptimizedDrawing()
           
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, alwaysOnTop, checkIfChildObscuredBySibling, componentInputMapChanged, computeVisibleRect, computeVisibleRect, compWriteObjectNotify, contains, createToolTip, disable, enable, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getManagingFocusBackwardTraversalKeys, getManagingFocusForwardTraversalKeys, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getWriteObjCounter, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, rectangleIsObscured, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, setWriteObjCounter, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, get, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, iterate, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, size, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, toString, transferFocus, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_LAYER

public static final Integer DEFAULT_LAYER
Suppressed: Convenience object defining the Default layer. Equivalent to new Integer(0).


PALETTE_LAYER

public static final Integer PALETTE_LAYER
Suppressed: Convenience object defining the Palette layer. Equivalent to new Integer(100).


MODAL_LAYER

public static final Integer MODAL_LAYER
Suppressed: Convenience object defining the Modal layer. Equivalent to new Integer(200).


POPUP_LAYER

public static final Integer POPUP_LAYER
Suppressed: Convenience object defining the Popup layer. Equivalent to new Integer(300).


DRAG_LAYER

public static final Integer DRAG_LAYER
Suppressed: Convenience object defining the Drag layer. Equivalent to new Integer(400).


FRAME_CONTENT_LAYER

public static final Integer FRAME_CONTENT_LAYER
Suppressed: Convenience object defining the Frame Content layer. This layer is normally only use to positon the contentPane and menuBar components of JFrame. Equivalent to new Integer(-30000).

See Also:
JFrame

LAYER_PROPERTY

public static final String LAYER_PROPERTY
Suppressed: Bound property


componentToLayer

private Hashtable componentToLayer

optimizedDrawingPossible

private boolean optimizedDrawingPossible
Constructor Detail

JLayeredPane

public JLayeredPane()
Suppressed: Create a new JLayeredPane

Method Detail

validateOptimizedDrawing

private void validateOptimizedDrawing()

addImpl

protected void addImpl(Component comp,
                       Object constraints,
                       int index)
Description copied from class: Container
Adds the specified component to this container at the specified index. This method also notifies the layout manager to add the component to this container's layout using the specified constraints object via the addLayoutComponent method. The constraints are defined by the particular layout manager being used. For example, the BorderLayout class defines five constraints: BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, and BorderLayout.CENTER.

Note that if the component already exists in this container or a child of this container, it is removed from that container before being added to this container.

This is the method to override if a program needs to track every add request to a container as all other add methods defer to this one. An overriding method should usually include a call to the superclass's version of the method:

super.addImpl(comp, constraints, index)

Overrides:
addImpl in class Container
Parameters:
comp - the component to be added
constraints - an object expressing layout constraints for this component
index - the position in the container's list at which to insert the component, where -1 means append to the end
See Also:
Container.add(Component), Container.add(Component, int), Container.add(Component, java.lang.Object), LayoutManager, LayoutManager2

remove

public void remove(int index)
Suppressed: Remove the indexed component from this pane. This is the absolute index, ignoring layers.

Overrides:
remove in class Container
Parameters:
index - an int specifying the component to remove
See Also:
getIndexOf(java.awt.Component)

isOptimizedDrawingEnabled

public boolean isOptimizedDrawingEnabled()
Suppressed: Returns false if components in the pane can overlap, which makes optimized drawing impossible. Otherwise, returns true.

Overrides:
isOptimizedDrawingEnabled in class JComponent
Returns:
false if components can overlap, else true
See Also:
JComponent.isOptimizedDrawingEnabled()

putLayer

public static void putLayer(JComponent c,
                            int layer)
Suppressed: Sets the layer property on a JComponent. This method does not cause any side effects like setLayer() (painting, add/remove, etc). Normally you should use the instance method setLayer(), in order to get the desired side-effects (like repainting).

Parameters:
c - the JComponent to move
layer - an int specifying the layer to move it to
See Also:
setLayer(java.awt.Component, int)

getLayer

public static int getLayer(JComponent c)
Suppressed: Gets the layer property for a JComponent, it does not cause any side effects like setLayer(). (painting, add/remove, etc) Normally you should use the instance method getLayer().

Parameters:
c - the JComponent to check
Returns:
an int specifying the component's layer

getLayeredPaneAbove

public static JLayeredPane getLayeredPaneAbove(Component c)
Suppressed: Convenience method that returns the first JLayeredPane which contains the specified component. Note that all JFrames have a JLayeredPane at their root, so any component in a JFrame will have a JLayeredPane parent.

Parameters:
c - the Component to check
Returns:
the JLayeredPane that contains the component, or null if no JLayeredPane is found in the component hierarchy
See Also:
JFrame, JRootPane

setLayer

public void setLayer(Component c,
                     int layer)
Suppressed: Sets the layer attribute on the specified component, making it the bottommost component in that layer. Should be called before adding to parent.

Parameters:
c - the Component to set the layer for
layer - an int specifying the layer to set, where lower numbers are closer to the bottom

setLayer

public void setLayer(Component c,
                     int layer,
                     int position)
Suppressed: Sets the layer attribute for the specified component and also sets its position within that layer.

Parameters:
c - the Component to set the layer for
layer - an int specifying the layer to set, where lower numbers are closer to the bottom
position - an int specifying the position within the layer, where 0 is the topmost position and -1 is the bottommost position

getLayer

public int getLayer(Component c)
Suppressed: Returns the layer attribute for the specified Component.

Parameters:
c - the Component to check
Returns:
an int specifying the component's current layer

getIndexOf

public int getIndexOf(Component c)
Suppressed: Returns the index of the specified Component. This is the absolute index, ignoring layers. Index numbers, like position numbers, have the topmost component at index zero. Larger numbers are closer to the bottom.

Parameters:
c - the Component to check
Returns:
an int specifying the component's index

moveToFront

public void moveToFront(Component c)
Suppressed: Moves the component to the top of the components in its current layer (position 0).

Parameters:
c - the Component to move
See Also:
setPosition(Component, int)

moveToBack

public void moveToBack(Component c)
Suppressed: Moves the component to the bottom of the components in its current layer (position -1).

Parameters:
c - the Component to move
See Also:
setPosition(Component, int)

setPosition

public void setPosition(Component c,
                        int position)
Suppressed: Moves the component to position within its current layer, where 0 is the topmost position within the layer and -1 is the bottommost position.

Note: Position numbering is defined by java.awt.Container, and is the opposite of layer numbering. Lower position numbers are closer to the top (0 is topmost), and higher position numbers are closer to the bottom.

Parameters:
c - the Component to move
position - an int in the range -1..N-1, where N is the number of components in the component's current layer

getPosition

public int getPosition(Component c)
Suppressed: Get the relative position of the component within its layer.

Parameters:
c - the Component to check
Returns:
an int giving the component's position, where 0 is the topmost position and the highest index value = the count count of components at that layer, minus 1
See Also:
getComponentCountInLayer(int)

highestLayer

public int highestLayer()
Suppressed: Returns the highest layer value from all current children. Returns 0 if there are no children.

Returns:
an int indicating the layer of the topmost component in the pane, or zero if there are no children

lowestLayer

public int lowestLayer()
Suppressed: Returns the lowest layer value from all current children. Returns 0 if there are no children.

Returns:
an int indicating the layer of the bottommost component in the pane, or zero if there are no children

getComponentCountInLayer

public int getComponentCountInLayer(int layer)
Suppressed: Returns the number of children currently in the specified layer.

Parameters:
layer - an int specifying the layer to check
Returns:
an int specifying the number of components in that layer

getComponentsInLayer

public Component[] getComponentsInLayer(int layer)
Suppressed: Returns an array of the components in the specified layer.

Parameters:
layer - an int specifying the layer to check
Returns:
an array of Components contained in that layer

paint

public void paint(Graphics g)
Suppressed: Paints this JLayeredPane within the specified graphics context.

Overrides:
paint in class JComponent
Parameters:
g - the Graphics context within which to paint
See Also:
JComponent.paintComponent(java.awt.Graphics), JComponent.paintBorder(java.awt.Graphics), JComponent.paintChildren(java.awt.Graphics), JComponent.getComponentGraphics(java.awt.Graphics), JComponent.repaint(long, int, int, int, int)

getComponentToLayer

protected Hashtable getComponentToLayer()
Returns the hashtable that maps components to layers.

Returns:
the Hashtable used to map components to their layers

getObjectForLayer

protected Integer getObjectForLayer(int layer)
Returns the Integer object associated with a specified layer.

Parameters:
layer - an int specifying the layer
Returns:
an Integer object for that layer

insertIndexForLayer

protected int insertIndexForLayer(int layer,
                                  int position)
Primitive method that determines the proper location to insert a new child based on layer and position requests.

Parameters:
layer - an int specifying the layer
position - an int specifying the position within the layer
Returns:
an int giving the (absolute) insertion-index
See Also:
getIndexOf(java.awt.Component)

paramString

protected String paramString()
Returns a string representation of this JLayeredPane. 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 JComponent
Returns:
a string representation of this JLayeredPane.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Suppressed: Gets the AccessibleContext associated with this JLayeredPane. For layered panes, the AccessibleContext takes the form of an AccessibleJLayeredPane. A new AccessibleJLayeredPane instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleJLayeredPane that serves as the AccessibleContext of this JLayeredPane


comments?