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

40
LINES

< > BotCompany Repo | #1014595 // flatInfoBox - show flat info message in top-left corner

JavaX fragment (include)

1  
static bool flatInfoBox_alwaysOnTop = true;
2  
static double flatInfoBox_defaultTime = 2.0;
3  
static int flatInfoBox_x = 28, flatInfoBox_y = 5;
4  
5  
// automatically switches to AWT thread for you
6  
static JWindow flatInfoBox(S text) {
7  
  ret flatInfoBox(text, flatInfoBox_defaultTime);
8  
}
9  
10  
static JWindow flatInfoBox(final S text, final double seconds) {
11  
  if (empty(text)) null;
12  
  print(text);
13  
  ret flatInfoBox_noprint(text, seconds);
14  
}
15  
16  
static JWindow flatInfoBox_noprint(S text) {
17  
  ret flatInfoBox_noprint(text, flatInfoBox_defaultTime);
18  
}
19  
20  
static JWindow flatInfoBox_noprint(final S text, final double seconds) {
21  
  if (empty(text)) null;
22  
  logQuotedWithDate(infoBoxesLogFile(), text); 
23  
  if (isHeadless()) null;
24  
  ret (JWindow) swingAndWait(func {
25  
    final JWindow window = makeUnimportantWindow(flatInfoBox_makePanel(text));
26  
    window.pack();
27  
    window.setBounds(flatInfoBox_x, flatInfoBox_y, 300, window.getHeight());
28  
    if (flatInfoBox_alwaysOnTop)
29  
      window.setAlwaysOnTop(true);
30  
    window.setVisible(true);
31  
    disposeWindowAfter(iround(seconds*1000), window);
32  
    ret window;
33  
  });
34  
}
35  
36  
static JWindow flatInfoBox(Throwable e) {
37  
  showConsole();
38  
  printStackTrace(e);
39  
  ret flatInfoBox(exceptionToStringShort(e));
40  
}

Author comment

Began life as a copy of #1006245

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: #1014595
Snippet name: flatInfoBox - show flat info message in top-left corner
Eternal ID of this version: #1014595/10
Text MD5: f0d03e8f72470b576e2df805981379c0
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-05 01:29:32
Source code size: 1260 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 317 / 374
Version history: 9 change(s)
Referenced in: [show references]