JLayeredPane and JDesktopPane

JLayeredPane and JDesktopPane 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 LayoutManager, 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. (By default the content panel has a 3x3 grid, all cells have a column weight and a row weight of 1 and a cell size of 32x32 pixels, the content panel is non-opaque.)
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 a panel, the panel can be moved inside the layered pane and has additional docking capabilities.
JLayeredPane with a content panel and a Mover  Ex. 22


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 box which is drawn around a single selected component. You can also set a component's location and size numerically.
Using a component's context menu 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 context menu.
See also:
    Inernal Frames and Palettes
    Mover