Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

60
LINES

< > BotCompany Repo | #1028304 // NestedDesktopPane Include

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (4233L) is out of date.

transient JDesktopPane desktopPane;
L<Win> 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();
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028304
Snippet name: NestedDesktopPane Include
Eternal ID of this version: #1028304/3
Text MD5: 0616ee7b7ad40325126b570372cf8c8c
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-09 12:51:03
Source code size: 1515 bytes / 60 lines
Pitched / IR pitched: No / No
Views / Downloads: 159 / 313
Version history: 2 change(s)
Referenced in: [show references]