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

54
LINES

< > BotCompany Repo | #1000921 // makeFrame (make JFrame and show it) - contains standard frame title popup menu

JavaX fragment (include)

1  
static S makeFrame_defaultIcon;
2  
sbool makeFrame_hideConsole;
3  
static new ThreadLocal<VF1<JFrame>> makeFrame_post;
4  
5  
static JFrame makeFrame() {
6  
  ret makeFrame((Component) null);
7  
}
8  
9  
static JFrame makeFrame(O content) {
10  
  ret makeFrame(programTitle(), content);
11  
}
12  
13  
static JFrame makeFrame(S title) {
14  
  ret makeFrame(title, null);
15  
}
16  
17  
static JFrame makeFrame(S title, O content) {
18  
  ret makeFrame(title, content, true);
19  
}
20  
21  
static JFrame makeFrame(fS title, fO content, final bool showIt) {
22  
  final VF1<JFrame> post = optParam(makeFrame_post);
23  
  ret swing(func -> JFrame {
24  
    if (getFrame(content) != null)
25  
      ret getFrame(setFrameTitle((Component) content, title));
26  
    final JFrame frame = new JFrame(title);
27  
    if (makeFrame_defaultIcon != null)
28  
      setFrameIconLater(frame, makeFrame_defaultIcon);
29  
    _initFrame(frame);
30  
    Component wrapped = wrap(content);
31  
    if (wrapped != null)
32  
      frame.getContentPane().add(wrapped);
33  
      
34  
    ifdef restrictAllWindowsToScreenSize
35  
      restrictWindowToScreenSize(frame);
36  
    endifdef
37  
    
38  
    frame.setBounds(defaultNewFrameBounds());
39  
    
40  
    callF(post, frame);
41  
    
42  
    if (showIt)
43  
      frame.setVisible(true);
44  
    //callOpt(content, "requestFocus");
45  
    //exitOnFrameClose(frame);
46  
    
47  
    if (showIt && makeFrame_hideConsole) {
48  
      hideConsole();
49  
      makeFrame_hideConsole = false;
50  
    }
51  
    
52  
    ret frame;
53  
  });
54  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1000921
Snippet name: makeFrame (make JFrame and show it) - contains standard frame title popup menu
Eternal ID of this version: #1000921/24
Text MD5: 14404f74d18a31a58fe20df75888680e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-20 19:45:48
Source code size: 1429 bytes / 54 lines
Pitched / IR pitched: No / No
Views / Downloads: 811 / 1833
Version history: 23 change(s)
Referenced in: [show references]