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)

static bool flatInfoBox_alwaysOnTop = true;
static double flatInfoBox_defaultTime = 2.0;
static int flatInfoBox_x = 28, flatInfoBox_y = 5;

// automatically switches to AWT thread for you
static JWindow flatInfoBox(S text) {
  ret flatInfoBox(text, flatInfoBox_defaultTime);
}

static JWindow flatInfoBox(final S text, final double seconds) {
  if (empty(text)) null;
  print(text);
  ret flatInfoBox_noprint(text, seconds);
}

static JWindow flatInfoBox_noprint(S text) {
  ret flatInfoBox_noprint(text, flatInfoBox_defaultTime);
}

static JWindow flatInfoBox_noprint(final S text, final double seconds) {
  if (empty(text)) null;
  logQuotedWithDate(infoBoxesLogFile(), text); 
  if (isHeadless()) null;
  ret (JWindow) swingAndWait(func {
    final JWindow window = makeUnimportantWindow(flatInfoBox_makePanel(text));
    window.pack();
    window.setBounds(flatInfoBox_x, flatInfoBox_y, 300, window.getHeight());
    if (flatInfoBox_alwaysOnTop)
      window.setAlwaysOnTop(true);
    window.setVisible(true);
    disposeWindowAfter(iround(seconds*1000), window);
    ret window;
  });
}

static JWindow flatInfoBox(Throwable e) {
  showConsole();
  printStackTrace(e);
  ret flatInfoBox(exceptionToStringShort(e));
}

Author comment

Began life as a copy of #1006245

download  show line numbers  debug dex   

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

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: 187 / 214
Version history: 9 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1014595 & http://1014595.tinybrain.de