!7 cmodule NestedDesktopPane { transient JDesktopPane desktopPane; L windows = syncL(); sclass Win { Rect rect; S title; transient JInternalFrame frame; !include #1027843 // setField } visualize { desktopPane = jDesktopPane(); restoreFrames(); ret withCenteredButtons(desktopPane, "Add frame", rThreadEnter addAFrame); } void unvisualize { super.unvisualize(); for (Win win : windows) win.frame = null; } void addAFrame { JInternalFrame f = showInternalFrame(desktopPane, "Hello world"); new Win win; win.rect = boundsAsRect(f); win.title = internalFrameTitle(f); win.frame = f; windows.add(win); onBoundsChange(f, r { grabRect(win) }); change(); } void restoreFrames { for (Win win : windows) win.frame = setBounds(win.rect, showInternalFrame(desktopPane, win.title)); } void grabRect(Win win) { if (win != null && win.frame != null && set_trueIfChanged(win, rect := boundsAsRect(win.frame))) change(); } }