()
| 38 | private SystemTray systemTray; |
| 39 | |
| 40 | public |
| 41 | TestReAddTray() { |
| 42 | SystemTray.DEBUG = true; // for test apps, we always want to run in debug mode |
| 43 | |
| 44 | // for test apps, make sure the cache is always reset. These are the ones used, and you should never do this in production. |
| 45 | CacheUtil.clear("SysTrayExample"); |
| 46 | |
| 47 | // SwingUtil.setLookAndFeel(null); // set Native L&F (this is the System L&F instead of CrossPlatform L&F) |
| 48 | // SystemTray.SWING_UI = new CustomSwingUI(); |
| 49 | |
| 50 | this.systemTray = SystemTray.get("SysTrayExample"); |
| 51 | if (systemTray == null) { |
| 52 | throw new RuntimeException("Unable to load SystemTray!"); |
| 53 | } |
| 54 | |
| 55 | systemTray.setTooltip("Mail Checker"); |
| 56 | systemTray.setImage(LT_GRAY_TRAIN); |
| 57 | systemTray.setStatus("No Mail"); |
| 58 | |
| 59 | systemTray.getMenu().add(new MenuItem("Quit", e->{ |
| 60 | systemTray.shutdown(); |
| 61 | //System.exit(0); not necessary if all non-daemon threads have stopped. |
| 62 | })).setShortcut('q'); // case does not matter |
| 63 | |
| 64 | |
| 65 | try { |
| 66 | Thread.sleep(3000); |
| 67 | } catch (InterruptedException e) { |
| 68 | e.printStackTrace(); |
| 69 | } |
| 70 | |
| 71 | System.err.println("Removing then adding new tray"); |
| 72 | |
| 73 | systemTray.remove(); |
| 74 | |
| 75 | systemTray = SystemTray.get("SysTrayExample"); |
| 76 | if (systemTray == null) { |
| 77 | throw new RuntimeException("Unable to load SystemTray!"); |
| 78 | } |
| 79 | |
| 80 | systemTray.setTooltip("Mail Checker"); |
| 81 | systemTray.setImage(LT_GRAY_TRAIN); |
| 82 | systemTray.setStatus("SUPER Mail"); |
| 83 | |
| 84 | systemTray.getMenu().add(new MenuItem("Quit", e->{ |
| 85 | systemTray.shutdown(); |
| 86 | //System.exit(0); not necessary if all non-daemon threads have stopped. |
| 87 | })).setShortcut('q'); // case does not matter |
| 88 | } |
| 89 | } |
nothing calls this directly
no test coverage detected