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

48
LINES

< > BotCompany Repo | #1003544 // showAnimationInTopRightCorner

JavaX fragment (include)

static bool showAnimationInTopRightCorner_alwaysOnTop = true;
static bool showAnimationInTopRightCorner_on = true;

// automatically switches to AWT thread for you
// text is optional text below image
static JWindow showAnimationInTopRightCorner(S imageID, S text) {
  if (isHeadless() || !showAnimationInTopRightCorner_on) null;
  ret showAnimationInTopRightCorner(imageIcon(imageID), text);
}

static JWindow showAnimationInTopRightCorner(final Image image, final S text) {
  if (image == null || isHeadless() || !showAnimationInTopRightCorner_on) null;
  ret showAnimationInTopRightCorner(imageIcon(image), text);
}

static JWindow showAnimationInTopRightCorner(final ImageIcon imageIcon, final S text) {
  if (isHeadless() || !showAnimationInTopRightCorner_on) null;
  ret (JWindow) swingAndWait(func {
    JLabel label = new JLabel(imageIcon);
    if (nempty(text)) {
      label.setText(text);
      label.setVerticalTextPosition(SwingConstants.BOTTOM);
      label.setHorizontalTextPosition(SwingConstants.CENTER);
    }
    final JWindow window = showInTopRightCorner(label);
    onClick(label, r { window.dispose() });
    if (showAnimationInTopRightCorner_alwaysOnTop)
      window.setAlwaysOnTop(true);
    ret window;
  });
}

static JWindow showAnimationInTopRightCorner(final S imageID) {
  ret showAnimationInTopRightCorner(imageID, "");
}

static JWindow showAnimationInTopRightCorner(S imageID, double seconds) {
  ret showAnimationInTopRightCorner(imageID, "", seconds);
}

static JWindow showAnimationInTopRightCorner(S imageID, S text, double seconds) {
  if (isHeadless()) null;
  ret disposeWindowAfter(iround(seconds*1000), showAnimationInTopRightCorner(imageID, text));
}

static JWindow showAnimationInTopRightCorner(BufferedImage img, S text, double seconds) {
  ret disposeWindowAfter(iround(seconds*1000), showAnimationInTopRightCorner(img, text));
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003544
Snippet name: showAnimationInTopRightCorner
Eternal ID of this version: #1003544/10
Text MD5: 15e2a720f2191dc0dca0b60aa72b6b18
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-12 02:14:03
Source code size: 1927 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 693 / 1215
Version history: 9 change(s)
Referenced in: [show references]