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.
-
DEFAULT_LAYER
-
-
DRAG_LAYER
-
-
LAYER_PROPERTY
-
-
MODAL_LAYER
-
-
paintBackground
-
-
PALETTE_LAYER
-
-
POPUP_LAYER
-
-
JLayeredPane()
-
-
addImpl(Component, Object, int)
-
-
getComponentCountInLayer(int)
- Returns the number of children currently in layer.
-
getComponentsInLayer(int)
- Returns an array of the components in layer.
-
getComponentToLayer()
-
-
getIndexOf(Component)
- Returns the index of this Component c.
-
getLayer(Component)
- Returns the layer attribute for this Component c.
-
getObjectForLayer(int)
-
-
getPosition(Component)
- Relative position with the component's layer.
-
highestLayer()
- Returns the highest layer value from all current children.
-
insertIndexForLayer(int, int)
- Primative method that determines the proper location to
insert a new child based on layer and position requests.
-
isBackgroundPainted()
-
-
isOpaque()
-
-
lowestLayer()
- Returns the lowest layer value from all current children.
-
moveToBack(Component)
- Moves the component to position -1 within it's current layer.
-
moveToFront(Component)
- Moves the component to position 0 within it's current layer.
-
paint(Graphics)
-
-
setBackgroundPainted(boolean)
-
-
setLayer(Component, int)
- Sets the layer attribute on c.
-
setLayer(Component, int, int)
- Sets the layer attribute on c.
-
setPosition(Component, int)
- Moves the component to position within it's current layer.
DEFAULT_LAYER
public static final int DEFAULT_LAYER
PALETTE_LAYER
public static final int PALETTE_LAYER
MODAL_LAYER
public static final int MODAL_LAYER
POPUP_LAYER
public static final int POPUP_LAYER
DRAG_LAYER
public static final int DRAG_LAYER
LAYER_PROPERTY
public static final String LAYER_PROPERTY
paintBackground
protected boolean paintBackground
JLayeredPane
public JLayeredPane()
addImpl
protected void addImpl(Component comp,
Object constraints,
int index)
- Overrides:
- addImpl in class Container
setLayer
public void setLayer(Component c,
int layer)
- Sets the layer attribute on c. Should be called before
adding to parent.
setLayer
public void setLayer(Component c,
int layer,
int position)
- Sets the layer attribute on c.
getLayer
public int getLayer(Component c)
- Returns the layer attribute for this Component c.
getIndexOf
public int getIndexOf(Component c)
- Returns the index of this Component c.
This is the absolute index, ignoring layers.
moveToFront
public void moveToFront(Component c)
- Moves the component to position 0 within it's current layer.
moveToBack
public void moveToBack(Component c)
- Moves the component to position -1 within it's current layer.
setPosition
public void setPosition(Component c,
int position)
- Moves the component to position within it's current layer.
getPosition
public int getPosition(Component c)
- Relative position with the component's layer.
highestLayer
public int highestLayer()
- Returns the highest layer value from all current children.
Returns 0 if there are not children.
lowestLayer
public int lowestLayer()
- Returns the lowest layer value from all current children.
Returns 0 if there are not children.
getComponentCountInLayer
public int getComponentCountInLayer(int layer)
- Returns the number of children currently in layer.
getComponentsInLayer
public Component[] getComponentsInLayer(int layer)
- Returns an array of the components in layer.
setBackgroundPainted
public void setBackgroundPainted(boolean b)
isBackgroundPainted
public boolean isBackgroundPainted()
isOpaque
public boolean isOpaque()
- Overrides:
- isOpaque in class JComponent
paint
public void paint(Graphics g)
- Overrides:
- paint in class JComponent
getComponentToLayer
protected Hashtable getComponentToLayer()
getObjectForLayer
protected Integer getObjectForLayer(int layer)
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