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

48
LINES

< > BotCompany Repo | #1009948 // addInternalFrame - add JInternalFrame to JDesktopPane and activate

JavaX fragment (include)

1  
static new ThreadLocal<Bool> addInternalFrame_dontSelect;
2  
static new ThreadLocal<Int> addInternalFrame_layer;
3  
static new ThreadLocal<Bool> addInternalFrame_toBack;
4  
5  
static JInternalFrame addInternalFrame(final JDesktopPane desktop, fS title, final int x, final int y, final int w, final int h) {
6  
  ret addInternalFrame(desktop, title, x, y, w, h, null);
7  
}
8  
9  
static JInternalFrame addInternalFrame(final JDesktopPane desktop, fS title, final int x, final int y, final int w, final int h, final Component contents) {
10  
  ret addInternalFrame(desktop, title, rect(x, y, w, h), contents);
11  
}
12  
13  
static JInternalFrame addInternalFrame(final JDesktopPane desktop, fS title, final Component contents) {
14  
  ret addInternalFrame(desktop, title, null, contents);
15  
}
16  
17  
static JInternalFrame addInternalFrame(final JDesktopPane desktop, fS title, final Rect r, final Component contents) {
18  
  final bool dontSelect = isTrue(optParam(addInternalFrame_dontSelect));
19  
  final bool toBack = isTrue(optParam(addInternalFrame_toBack));
20  
  final Int layer = optParam(addInternalFrame_layer);
21  
  ret swing(func -> JInternalFrame {
22  
    JInternalFrame frame;
23  
    if (contents instanceof JInternalFrame)
24  
      frame = (JInternalFrame) contents;
25  
    else {
26  
      frame = jInternalFrame(title);
27  
      setInternalFrameContents(frame, contents);
28  
    }
29  
    frame.setVisible(true);
30  
    desktop.add(frame, layer);
31  
    if (r != null)
32  
      setBounds(frame, r);
33  
    else
34  
      internalFrameDefaultPosition(frame);
35  
    if (dontSelect)
36  
      if (toBack)
37  
        frame.toBack();
38  
      else
39  
        frame.toFront();
40  
    else
41  
      frame.setSelected(true);
42  
    ret fixInternalFrame(frame);
43  
  });
44  
}
45  
46  
static JInternalFrame addInternalFrame(JDesktopPane desktop, S title) {
47  
  ret addInternalFrame(desktop, title, jpanel());
48  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009948
Snippet name: addInternalFrame - add JInternalFrame to JDesktopPane and activate
Eternal ID of this version: #1009948/30
Text MD5: 12933e9477714d5ccd99fc26743fbb71
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-15 03:33:15
Source code size: 1818 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 750 / 790
Version history: 29 change(s)
Referenced in: [show references]