DesktopPane
The desktop of a multi-document application, realized as a JDesktopPane: the surface the internal frames content declares float on.
Declare the frames you need; each InternalFrame(...) becomes a JInternalFrame floating on the desktop with its own title, position, size, and window controls. Frames are dynamic: adding or removing an InternalFrame(...) adds or removes the frame it identifies (see DesktopPaneScope), and a frame's title, controls, and bounds update on recomposition.
A frame is the one thing a desktop holds, and it holds as many of them as content declares: every child of the pane is an InternalFrame(...), and anything else composed here is refused. Compose it inside a frame's body instead.
The close control is controlled: activating it invokes the frame's onClose rather than closing the frame on its own. Remove the frame from the composition in response to actually close it.
A frame declared with plain bounds sits where the declaration puts it and, for as long as the composition goes on declaring it in the same place (see DesktopPaneScope), stays wherever the user leaves it. Declare it with an InternalFrameState instead to make its geometry and its window state two-way: assigning to the state moves, resizes, iconifies or maximizes the frame, and the user dragging the frame, pulling its border or activating its iconify, maximize or restore control writes the new value back into the state.
A frame's window transitions (opened, closing, closed, activated, deactivated, and iconified and deiconified again) are among the events the InternalFrame overloads taking an InternalFrameListener deliver.
val editor = rememberInternalFrameState(bounds = Rectangle(0, 0, 300, 200))
var editorOpen by remember { mutableStateOf(true) }
var consoleOpen by remember { mutableStateOf(true) }
DesktopPane {
if (editorOpen) {
InternalFrame(title = "Editor", state = editor, onClose = { editorOpen = false }) { Editor() }
}
if (consoleOpen) {
InternalFrame(
title = "Console",
bounds = Rectangle(40, 40, 300, 200),
onClose = { consoleOpen = false },
) { Console() }
}
}Parameters
the SwingModifier applied to the underlying JDesktopPane
declares the internal frames; see DesktopPaneScope