Transpiled version (5627L) is out of date.
1 | sbool trayIcon_imageAutoSize = true; |
2 | |
3 | static TrayIcon installTrayIcon(S imageID, S tooltip) { |
4 | ret installTrayIcon(imageID, tooltip, null); |
5 | } |
6 | |
7 | // menuItems can also just be a PopupMenu |
8 | // also, first of menuItems can be a Runnable for left-click on icon |
9 | static TrayIcon installTrayIcon(S imageID, S tooltip, O... menuItems) ctex { |
10 | // convenience parameter swap :-) |
11 | |
12 | if (!isSnippetID(imageID) && isSnippetID(tooltip)) { |
13 | S s = tooltip; |
14 | tooltip = imageID; |
15 | imageID = s; |
16 | } |
17 | |
18 | ifdef installTrayIcon_useImageIcon |
19 | Image image = imageIcon(imageID).getImage(); |
20 | endifdef |
21 | ifndef installTrayIcon_useImageIcon |
22 | Image image = loadImage2(imageID); |
23 | endifndef |
24 | ret installTrayIcon(image, tooltip, menuItems); |
25 | } |
26 | |
27 | static TrayIcon installTrayIcon(final Image image, fS tooltip, fO... _menuItems) null on exception { |
28 | ret swing(func -> TrayIcon { |
29 | Runnable leftClick = null; |
30 | O[] menuItems = params_unpackList(_menuItems); |
31 | if (l(menuItems) > 0 && menuItems[0] instanceof Runnable) { |
32 | leftClick = (Runnable) menuItems[0]; |
33 | menuItems = dropFirst(menuItems); |
34 | } |
35 | |
36 | PopupMenu menu = makePopupMenu(menuItems); |
37 | TrayIcon trayIcon = new TrayIcon(image, tooltip, menu); |
38 | trayIcon.setImageAutoSize(trayIcon_imageAutoSize); |
39 | |
40 | if (leftClick != null) { |
41 | final Runnable _leftClick = leftClick; |
42 | onLeftClick(trayIcon, _leftClick); |
43 | } |
44 | |
45 | SystemTray.getSystemTray().add(trayIcon); |
46 | ret trayIcon; |
47 | }); |
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: | #1003656 |
Snippet name: | installTrayIcon - takes image ID and menu item params |
Eternal ID of this version: | #1003656/15 |
Text MD5: | 035a541396f051ec7d56eaa9072511cf |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-28 22:07:36 |
Source code size: | 1506 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 734 / 884 |
Version history: | 14 change(s) |
Referenced in: | [show references] |