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

41
LINES

< > BotCompany Repo | #1015529 - infoBox_centeredText

JavaX fragment (include)

please include function infoMessage.

static JWindow infoBox_centeredText(S text) {
  ret infoBox_centeredText(text, infoMessage_defaultTime);
}

static JWindow infoBox_centeredText(final S text, final double seconds) {
  print(text);
  ret infoMessage_noprint(text, seconds);
}

static JWindow infoBox_centeredText_noprint(S text) {
  ret infoBox_centeredText_noprint(text, infoMessage_defaultTime);
}

static JWindow infoBox_centeredText_noprint(final S text, final double seconds) {
  if (empty(text)) null;
  logQuotedWithDate(infoBoxesLogFile(), text); 
  if (isHeadless()) null;
  ret (JWindow) swingAndWait(func {
    JWindow window = makeWindow(infoBox_centeredText_makePanel(text));
    window.setSize(300, 150);
    moveToTopRightCorner(window);
    if (infoMessage_alwaysOnTop)
      window.setAlwaysOnTop(true);
    window.setVisible(true);
    disposeWindowAfter(iround(seconds*1000), window);
    ret window;
  });
}

static JPanel infoBox_centeredText_makePanel(S text) {
  final JTextPane ta = jcenteredtextpane(text);
  onClick(ta, r { disposeWindow(ta) });
  int size = 14;
  if (l(text) <= 50) size *= 2;
  else if (l(text) < 100) size = iround(size*1.5);
  ta.setFont(typeWriterFont(size));
  JScrollPane sp = jscroll(ta);
  ret withMargin(sp);
}

Author comment

Began life as a copy of #1006245

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1015529
Snippet name: infoBox_centeredText
Eternal ID of this version: #1015529/5
Text MD5: a9a629980743426f39a4c494249938e9
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-27 09:46:04
Source code size: 1306 bytes / 41 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 260
Version history: 4 change(s)
Referenced in: [show references]