Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--com.sun.java.swing.JComponent | +--com.sun.java.swing.JLayeredPane
|
moveToFront(Component)
,
moveToBack(Component)
and setPosition
can be used
to reposition a component within its layer. The setLayer
method
can also be used to change the component's current layer.
Each layer is a distinct integer number. The layer attribute can be set
on a Component by passing an Integer object during the add call.
For example:
layeredPane.add(child, JLayeredPane.DEFAULT_LAYER); or layeredPane.add(child, new Integer(10));The layer attribute can also be set on a Component by calling
layeredPaneParent.setLayer(child, 10)on the JLayeredPane that is the parent of component. The layer should be set before adding the child to the parent.
Higher number layers display above lower number layers. So, using numbers for the layers and letters for individual components, a representative list order would look like this:
5a, 5b, 5c, 2a, 2b, 2c, 1awhere the leftmost components are closest to the top of the display.
A component can be moved to the top or bottom position within its
layer by calling moveToFront
or moveToBack
.
The position of a component within a layer can also be specified directly. Valid positions range from 0 up to one less than the number of components in that layer. A value of -1 indicates the bottommost position. A value of 0 indicates the topmost position. Unlike layer numbers, higher position values are lower in the display.
Note: This sequence (defined by java.awt.Container) is the reverse of the layer numbering sequence. Usually though, you will useHere are some examples using the method add(Component, layer, position): Calling add(5x, 5, -1) results in:moveToFront
,moveToBack
, andsetLayer
.
5a, 5b, 5c, 5x, 2a, 2b, 2c, 1aCalling add(5z, 5, 2) results in:
5a, 5b, 5z, 5c, 5x, 2a, 2b, 2c, 1aCalling add(3a, 3, 7) results in:
5a, 5b, 5z, 5c, 5x, 3a, 2a, 2b, 2c, 1aUsing normal paint/event mechanics results in 1a appearing at the bottom and 5a being above all other components.
Note: that these layers are simply a logical construct and LayoutManagers will affect all child components of this container without regard for layer settings.
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 Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.
Inner Class Summary | |
JLayeredPane.AccessibleJLayeredPane
The class used to obtain the accessible role for this object. |
Inner classes inherited from class com.sun.java.swing.JComponent | |
JComponent.AccessibleJComponent |
Field Summary | |
static java.lang.Integer | DEFAULT_LAYER
Convenience object defining the Default layer. |
static java.lang.Integer | DRAG_LAYER
Convenience object defining the Drag layer. |
static java.lang.Integer | FRAME_CONTENT_LAYER
Convenience object defining the Frame Content layer. |
static java.lang.String | LAYER_PROPERTY
Bound property |
static java.lang.Integer | MODAL_LAYER
Convenience object defining the Modal layer. |
static java.lang.Integer | PALETTE_LAYER
Convenience object defining the Palette layer. |
static java.lang.Integer | POPUP_LAYER
Convenience object defining the Popup layer. |
Fields inherited from class com.sun.java.swing.JComponent | |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component | |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Constructor Summary | |
JLayeredPane()
Create a new JLayeredPane |
Method Summary | |
void | addImpl(java.awt.Component comp,
java.lang.Object constraints,
int index)
|
AccessibleContext | getAccessibleContext()
Get the AccessibleContext associated with this JComponent |
int | getComponentCountInLayer(int layer)
Returns the number of children currently in the specified layer. |
java.awt.Component[] | getComponentsInLayer(int layer)
Returns an array of the components in the specified layer. |
java.util.Hashtable | getComponentToLayer()
Returns the hashtable that maps components to layers. |
int | getIndexOf(java.awt.Component c)
Returns the index of the specified Component. |
static JLayeredPane | getLayeredPaneAbove(java.awt.Component c)
Convenience method that returns the first JLayeredPane which contains the specified component. |
static int | getLayer(JComponent c)
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(). |
int | getLayer(java.awt.Component c)
Returns the layer attribute for the specified Component. |
java.lang.Integer | getObjectForLayer(int layer)
Returns the Integer object associated with a specified layer. |
int | getPosition(java.awt.Component c)
Get the relative position of the component within its layer. |
int | highestLayer()
Returns the highest layer value from all current children. |
int | insertIndexForLayer(int layer,
int position)
Primative method that determines the proper location to insert a new child based on layer and position requests. |
boolean | isOptimizedDrawingEnabled()
Returns false if components in the pane can overlap, which makes optimized drawing impossible. |
int | lowestLayer()
Returns the lowest layer value from all current children. |
void | moveToBack(java.awt.Component c)
Moves the component to the bottom of the components in it's current layer (position -1). |
void | moveToFront(java.awt.Component c)
Moves the component to the top of the components in it's current layer (position 0). |
void | paint(java.awt.Graphics g)
Paints this JLayeredPane within the specified graphics context. |
static void | putLayer(JComponent c,
int layer)
Sets the layer property on a JComponent. |
void | remove(int index)
Remove the indexed component from this pane. |
void | setLayer(java.awt.Component c,
int layer)
Sets the layer attribute on the specified component, making it the bottommost component in that layer. |
void | setLayer(java.awt.Component c,
int layer,
int position)
Sets the layer attribute for the specified component and also sets its position within that layer. |
void | setPosition(java.awt.Component c,
int position)
Moves the component to position within it's current layer,
where 0 is the topmost position within the layer and -1 is the bottommost
position.
|
Methods inherited from class java.awt.Container | |
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponentAt, getComponentAt, getComponent, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paint, paramString, preferredSize, printComponents, print, processContainerEvent, processEvent, removeAll, remove, remove, removeContainerListener, removeNotify, setLayout, update, validate, validateTree |
Methods inherited from class java.awt.Component | |
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Field Detail |
public static final java.lang.Integer DEFAULT_LAYER
public static final java.lang.Integer PALETTE_LAYER
public static final java.lang.Integer MODAL_LAYER
public static final java.lang.Integer POPUP_LAYER
public static final java.lang.Integer DRAG_LAYER
public static final java.lang.Integer FRAME_CONTENT_LAYER
public static final java.lang.String LAYER_PROPERTY
Constructor Detail |
public JLayeredPane()
Method Detail |
protected void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
public void remove(int index)
index
- an int specifying the component to removepublic boolean isOptimizedDrawingEnabled()
public static void putLayer(JComponent c, int layer)
c
- the JComponent to move
layer
- an int specifying the layer to move it topublic static int getLayer(JComponent c)
c
- the JComponent to checkpublic static JLayeredPane getLayeredPaneAbove(java.awt.Component c)
c
- the Component to checkpublic void setLayer(java.awt.Component c, int layer)
c
- the Component to set the layer for
layer
- an int specifying the layer to set, where
lower numbers are closer to the bottompublic void setLayer(java.awt.Component c, int layer, int position)
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 positionpublic int getLayer(java.awt.Component c)
c
- the Component to checkpublic int getIndexOf(java.awt.Component c)
c
- the Component to checkpublic void moveToFront(java.awt.Component c)
c
- the Component to movepublic void moveToBack(java.awt.Component c)
c
- the Component to movepublic void setPosition(java.awt.Component c, int position)
position
within it's 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.
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 layerpublic int getPosition(java.awt.Component c)
c
- the Component to checkpublic int highestLayer()
public int lowestLayer()
public int getComponentCountInLayer(int layer)
layer
- an int specifying the layer to checkpublic java.awt.Component[] getComponentsInLayer(int layer)
layer
- an int specifying the layer to checkpublic void paint(java.awt.Graphics g)
g
- the Graphics context within which to paintprotected java.util.Hashtable getComponentToLayer()
protected java.lang.Integer getObjectForLayer(int layer)
layer
- an int specifying the layerprotected int insertIndexForLayer(int layer, int position)
layer
- an int specifying the layer
position
- an int specifying the position within the layerpublic AccessibleContext getAccessibleContext()
Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |