transient JDesktopPane desktopPane; L windows = syncL(); sclass Win { Rect rect; S title; transient JInternalFrame frame; } JComponent NestedDesktopPane_visualize() { ret desktopPane = jDesktopPane(); } // Restoring frames in visualize() leads to the module menu not accessible after // reload when there is at least one subwindow. So we do it here instead. void NestedDesktopPane_enhanceFrame(JInternalFrame f) { restoreFrames(); } void NestedDesktopPane_unvisualize { super.unvisualize(); for (Win win : windows) win.frame = null; } JInternalFrame addAFrame(S title) { JInternalFrame f = showInternalFrame(desktopPane, title); new Win win; win.rect = boundsAsRect(f); win.title = title; setWinFrame(win, f); windows.add(win); change(); ret f; } void setWinFrame(Win win, JInternalFrame f) { setIconifiable(f, false); win.frame = f; onBoundsChange(f, r { grabRect(win) }); onInternalFrameClosing(f, r { win.frame = null; removeWin(win) }); onTitleChanged(f, r { if (set_trueIfChanged(win, title := internalFrameTitle(f))) change() }); } void restoreFrames { if (desktopPane == null) ret; for (Win win : windows) setWinFrame(win, 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(); } void removeWin(Win win) { if (windows.remove(win)) { disposeInternalFrame(win.frame); change(); } }