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

48
LINES

< > BotCompany Repo | #1003544 // showAnimationInTopRightCorner

JavaX fragment (include)

1  
static bool showAnimationInTopRightCorner_alwaysOnTop = true;
2  
static bool showAnimationInTopRightCorner_on = true;
3  
4  
// automatically switches to AWT thread for you
5  
// text is optional text below image
6  
static JWindow showAnimationInTopRightCorner(S imageID, S text) {
7  
  if (isHeadless() || !showAnimationInTopRightCorner_on) null;
8  
  ret showAnimationInTopRightCorner(imageIcon(imageID), text);
9  
}
10  
11  
static JWindow showAnimationInTopRightCorner(final Image image, final S text) {
12  
  if (image == null || isHeadless() || !showAnimationInTopRightCorner_on) null;
13  
  ret showAnimationInTopRightCorner(imageIcon(image), text);
14  
}
15  
16  
static JWindow showAnimationInTopRightCorner(final ImageIcon imageIcon, final S text) {
17  
  if (isHeadless() || !showAnimationInTopRightCorner_on) null;
18  
  ret (JWindow) swingAndWait(func {
19  
    JLabel label = new JLabel(imageIcon);
20  
    if (nempty(text)) {
21  
      label.setText(text);
22  
      label.setVerticalTextPosition(SwingConstants.BOTTOM);
23  
      label.setHorizontalTextPosition(SwingConstants.CENTER);
24  
    }
25  
    final JWindow window = showInTopRightCorner(label);
26  
    onClick(label, r { window.dispose() });
27  
    if (showAnimationInTopRightCorner_alwaysOnTop)
28  
      window.setAlwaysOnTop(true);
29  
    ret window;
30  
  });
31  
}
32  
33  
static JWindow showAnimationInTopRightCorner(final S imageID) {
34  
  ret showAnimationInTopRightCorner(imageID, "");
35  
}
36  
37  
static JWindow showAnimationInTopRightCorner(S imageID, double seconds) {
38  
  ret showAnimationInTopRightCorner(imageID, "", seconds);
39  
}
40  
41  
static JWindow showAnimationInTopRightCorner(S imageID, S text, double seconds) {
42  
  if (isHeadless()) null;
43  
  ret disposeWindowAfter(iround(seconds*1000), showAnimationInTopRightCorner(imageID, text));
44  
}
45  
46  
static JWindow showAnimationInTopRightCorner(BufferedImage img, S text, double seconds) {
47  
  ret disposeWindowAfter(iround(seconds*1000), showAnimationInTopRightCorner(img, text));
48  
}

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