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.

1  
transient JDesktopPane desktopPane;
2  
L<Win> windows = syncL();
3  
4  
sclass Win {
5  
  Rect rect;
6  
  S title;
7  
  transient JInternalFrame frame;
8  
}
9  
10  
JComponent NestedDesktopPane_visualize() { ret desktopPane = jDesktopPane(); }
11  
12  
// Restoring frames in visualize() leads to the module menu not accessible after
13  
// reload when there is at least one subwindow. So we do it here instead.
14  
void NestedDesktopPane_enhanceFrame(JInternalFrame f) {
15  
  restoreFrames();
16  
}
17  
18  
void NestedDesktopPane_unvisualize {
19  
  super.unvisualize();
20  
  for (Win win : windows) win.frame = null;
21  
}
22  
23  
JInternalFrame addAFrame(S title) {
24  
  JInternalFrame f = showInternalFrame(desktopPane, title);
25  
  new Win win;
26  
  win.rect = boundsAsRect(f);
27  
  win.title = title;
28  
  setWinFrame(win, f);
29  
  windows.add(win);
30  
  change();
31  
  ret f;
32  
}
33  
34  
void setWinFrame(Win win, JInternalFrame f) {
35  
  setIconifiable(f, false);
36  
  win.frame = f;
37  
  onBoundsChange(f, r { grabRect(win) });
38  
  onInternalFrameClosing(f, r { win.frame = null; removeWin(win) });
39  
  onTitleChanged(f, r {
40  
    if (set_trueIfChanged(win, title := internalFrameTitle(f))) change()
41  
  });
42  
}
43  
44  
void restoreFrames {
45  
  if (desktopPane == null) ret;
46  
  for (Win win : windows)
47  
    setWinFrame(win, setBounds(win.rect, showInternalFrame(desktopPane, win.title)));
48  
}
49  
50  
void grabRect(Win win) {
51  
  if (win != null && win.frame != null && set_trueIfChanged(win, rect := boundsAsRect(win.frame)))
52  
    change();
53  
}
54  
55  
void removeWin(Win win) {
56  
  if (windows.remove(win)) {
57  
    disposeInternalFrame(win.frame);
58  
    change();
59  
  }
60  
}

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: 96 / 225
Version history: 2 change(s)
Referenced in: [show references]