JLayeredPane and JDesktopPane

and both provide a component Z-order, allowing components to overlap each other when needed. In contrast to JLayeredPane, JDesktopPane additionally has an instance of DesktopManager which provides window management for internal frames (allowing you to develop multi-document applications).

Both JLayeredPane and JDesktopPane have a null layout manager, this means, child components are not arranged in a layout but each component is displayed within its own bounds (a Rectangle object specifying the components location and display size).

Working with null-layouts can be difficult but RADi provides some mechanisms to ease this task:
A component or container added to JLayeredPane or JDesktopPane is guaranteed to be displayed at least at its preferred size.
You cannot move components outside their parent container.
You can add a content panel to a JLayeredPane or JDesktopPane.
The content panel is an ordinary RADi grid which will always be of exactly the same size as its parent container and will be displayed behind all other components. (The content panel, by default, is non-opaque, has a 3x3 grid and all cells have a column weight and a row weight of 1.)
Using a content panel combines the best of both worlds: moveable and overlapping components and a reliable and resizable grid.
By adding a Mover to any container, the container can be moved inside the layered pane and has additional docking capabilities (see Mover).

To become familiar with null-layout containers, start by dragging a JLayeredPane or JDesktopPane to the design grid.
You will notice, that the container's preferredSize property is set to Dimension(240,180) by default. Because the container doesn't have a LayoutManager, setting its preferredSize property is essential.

Working with null layouts

To place a component inside a null-layout, drag it to the JLayeredPane or JDesktopPane. The component's location will be the location where the mouse button was released and the component's size will be its preferred size.

If you paste one or more components into a null-layout, the components' location will be at (10/10, 20/20, ...) and the components' sizes will be their preferred sizes.

Components can be moved with the mouse or by using the arrow keys.
To change a component's size, adjust the which is drawn around a single selected component.

Tip: You can set a component's location and size numerically from the .

Using a component's , you can change its Z-position, you can hide the component and you can reset its bounds to the component's preferred size.

To add a content panel to a JLayeredPane or JDesktopPane, select 'Add Content Panel' from the container's .

See also:
Mover
Internal Frames