All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.JLayeredPane

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JLayeredPane

public class JLayeredPane
extends JComponent

JLayeredPane manages it's list of children like Container, but allows for the definition of a several layers within itself. Children in the same layer are managed exactly like the normal Container object, with the added feature that children in higher layers display above the children in lower layers. Each layer is a distinct integer number.

The layer attribute can be set on a Component by calling setLayer(component, layer) on the JLayeredPane that will be the parent of component. The layer should be set before adding the child to the parent.

 Higher number layers display above lower number layers.
 Where numbers are the layers and letter indicate individual components:
 A represenative list order looks like this:
       5a, 5b, 5c, 2a, 2b, 2c, 1a
 Using the method add(Component, layer, position):
 Calling add(5x, 5, -1) results in:
       5a, 5b, 5c, 5x, 2a, 2b, 2c, 1a
 Calling add(5z, 5, 2) results in:
       5a, 5b, 5z, 5c, 5x, 2a, 2b, 2c, 1a
 Calling add(3a, 3, 7) results in:
       5a, 5b, 5z, 5c, 5x, 3a, 2a, 2b, 2c, 1a
 Using normal paint/event mechanics results in 1a appearing at the bottom
 and 5a being above all other components.
 


Variable Index

 o DEFAULT_LAYER
 o DRAG_LAYER
 o LAYER_PROPERTY
 o MODAL_LAYER
 o paintBackground
 o PALETTE_LAYER
 o POPUP_LAYER

Constructor Index

 o JLayeredPane()

Method Index

 o addImpl(Component, Object, int)
 o getComponentCountInLayer(int)
Returns the number of children currently in layer.
 o getComponentsInLayer(int)
Returns an array of the components in layer.
 o getComponentToLayer()
 o getIndexOf(Component)
Returns the index of this Component c.
 o getLayer(Component)
Returns the layer attribute for this Component c.
 o getObjectForLayer(int)
 o getPosition(Component)
Relative position with the component's layer.
 o highestLayer()
Returns the highest layer value from all current children.
 o insertIndexForLayer(int, int)
Primative method that determines the proper location to insert a new child based on layer and position requests.
 o isBackgroundPainted()
 o isOpaque()
 o lowestLayer()
Returns the lowest layer value from all current children.
 o moveToBack(Component)
Moves the component to position -1 within it's current layer.
 o moveToFront(Component)
Moves the component to position 0 within it's current layer.
 o paint(Graphics)
 o setBackgroundPainted(boolean)
 o setLayer(Component, int)
Sets the layer attribute on c.
 o setLayer(Component, int, int)
Sets the layer attribute on c.
 o setPosition(Component, int)
Moves the component to position within it's current layer.

Variables

 o DEFAULT_LAYER
 public static final int DEFAULT_LAYER
 o PALETTE_LAYER
 public static final int PALETTE_LAYER
 o MODAL_LAYER
 public static final int MODAL_LAYER
 o POPUP_LAYER
 public static final int POPUP_LAYER
 o DRAG_LAYER
 public static final int DRAG_LAYER
 o LAYER_PROPERTY
 public static final String LAYER_PROPERTY
 o paintBackground
 protected boolean paintBackground

Constructors

 o JLayeredPane
 public JLayeredPane()

Methods

 o addImpl
 protected void addImpl(Component comp,
                        Object constraints,
                        int index)
Overrides:
addImpl in class Container
 o setLayer
 public void setLayer(Component c,
                      int layer)
Sets the layer attribute on c. Should be called before adding to parent.

 o setLayer
 public void setLayer(Component c,
                      int layer,
                      int position)
Sets the layer attribute on c.

 o getLayer
 public int getLayer(Component c)
Returns the layer attribute for this Component c.

 o getIndexOf
 public int getIndexOf(Component c)
Returns the index of this Component c. This is the absolute index, ignoring layers.

 o moveToFront
 public void moveToFront(Component c)
Moves the component to position 0 within it's current layer.

 o moveToBack
 public void moveToBack(Component c)
Moves the component to position -1 within it's current layer.

 o setPosition
 public void setPosition(Component c,
                         int position)
Moves the component to position within it's current layer.

 o getPosition
 public int getPosition(Component c)
Relative position with the component's layer.

 o highestLayer
 public int highestLayer()
Returns the highest layer value from all current children. Returns 0 if there are not children.

 o lowestLayer
 public int lowestLayer()
Returns the lowest layer value from all current children. Returns 0 if there are not children.

 o getComponentCountInLayer
 public int getComponentCountInLayer(int layer)
Returns the number of children currently in layer.

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

 o setBackgroundPainted
 public void setBackgroundPainted(boolean b)
 o isBackgroundPainted
 public boolean isBackgroundPainted()
 o isOpaque
 public boolean isOpaque()
Overrides:
isOpaque in class JComponent
 o paint
 public void paint(Graphics g)
Overrides:
paint in class JComponent
 o getComponentToLayer
 protected Hashtable getComponentToLayer()
 o getObjectForLayer
 protected Integer getObjectForLayer(int layer)
 o insertIndexForLayer
 protected int insertIndexForLayer(int layer,
                                   int position)
Primative method that determines the proper location to insert a new child based on layer and position requests.


All Packages  Class Hierarchy  This Package  Previous  Next  Index