()
| 40 | private SystemTray systemTray2; |
| 41 | |
| 42 | public |
| 43 | TestMultiTray() { |
| 44 | SystemTray.DEBUG = true; // for test apps, we always want to run in debug mode |
| 45 | |
| 46 | // for test apps, make sure the cache is always reset. These are the ones used, and you should never do this in production. |
| 47 | CacheUtil.clear("SysTrayExample1"); |
| 48 | CacheUtil.clear("SysTrayExample2"); |
| 49 | |
| 50 | // SwingUtil.setLookAndFeel(null); // set Native L&F (this is the System L&F instead of CrossPlatform L&F) |
| 51 | // SystemTray.SWING_UI = new CustomSwingUI(); |
| 52 | |
| 53 | this.systemTray1 = SystemTray.get("SysTrayExample1"); |
| 54 | if (systemTray1 == null) { |
| 55 | throw new RuntimeException("Unable to load SystemTray!"); |
| 56 | } |
| 57 | |
| 58 | systemTray1.setTooltip("Mail Checker"); |
| 59 | systemTray1.setImage(LT_GRAY_TRAIN); |
| 60 | systemTray1.setStatus("No Mail"); |
| 61 | |
| 62 | systemTray1.getMenu().add(new MenuItem("Quit", e->{ |
| 63 | System.err.println("Quit 1"); |
| 64 | systemTray1.shutdown(); |
| 65 | //System.exit(0); not necessary if all non-daemon threads have stopped. |
| 66 | })).setShortcut('q'); // case does not matter |
| 67 | |
| 68 | |
| 69 | System.err.println("Creating another tray"); |
| 70 | |
| 71 | |
| 72 | systemTray2 = SystemTray.get("SysTrayExample2"); |
| 73 | if (systemTray2 == null) { |
| 74 | throw new RuntimeException("Unable to load SystemTray!"); |
| 75 | } |
| 76 | |
| 77 | // SWT/JavaFX "shutdown hooks" have changed. Since it's no longer available with JPMS, it is no longer supported. |
| 78 | // Developers must add the shutdown hooks themselves. |
| 79 | |
| 80 | systemTray2.setTooltip("Choo-Choo!"); |
| 81 | systemTray2.setImage(GREEN_TRAIN); |
| 82 | systemTray2.setStatus("HONK"); |
| 83 | |
| 84 | systemTray2.getMenu().add(new MenuItem("Quit", e->{ |
| 85 | System.err.println("Quit 2"); |
| 86 | systemTray2.shutdown(); |
| 87 | //System.exit(0); not necessary if all non-daemon threads have stopped. |
| 88 | })).setShortcut('q'); // case does not matter |
| 89 | } |
| 90 | } |
nothing calls this directly
no test coverage detected