74 g.setColor(c); 75 g.fillRect(0, 0, w, h); 76 g.setColor(Color.WHITE); 77 int r = (Math.min(w, h) >= 8) ? 3 : 1; 78 g.fillRect(r, r, w - 2 * r, h - 2 * r); 79 return img; 80 } 81 82 private void prepareIcons() { 83 84 tray = SystemTray.getSystemTray(); 85 Dimension d = tray.getTrayIconSize(); 86 int w = d.width, h = d.height; 87 88 BufferedImage img = generateImage(w, h, Color.BLUE); 89 // use wrong icon size for "nok" 90 BufferedImage nok = generateImage(w / 2 + 2, h / 2 + 2, Color.RED); 91 BaseMultiResolutionImage mri = 92 new BaseMultiResolutionImage(new BufferedImage[] {nok, img}); 93 icon = new TrayIcon(img); 94 iconMRI = new TrayIcon(mri); 95 } 96 97 private void doTest() { 98 99 if (tray.getTrayIcons().length > 0) { return; } // icons were added already 100 try { 101 tray.add(icon); 102 tray.add(iconMRI); 103 } catch (Exception e) { 104 throw new RuntimeException(e); 105 } 106 } 107 108 public void stop() { 109 110 // check for null, just in case 111 if (tray != null) { 112 tray.remove(icon); 113 tray.remove(iconMRI); 114 } | 74 g.setColor(c); 75 g.fillRect(0, 0, w, h); 76 g.setColor(Color.WHITE); 77 int r = (Math.min(w, h) >= 8) ? 3 : 1; 78 g.fillRect(r, r, w - 2 * r, h - 2 * r); 79 return img; 80 } 81 82 private void prepareIcons() { 83 84 tray = SystemTray.getSystemTray(); 85 Dimension d = tray.getTrayIconSize(); 86 int w = d.width, h = d.height; 87 88 BufferedImage img = generateImage(w, h, Color.BLUE); 89 // use wrong icon size for "nok" 90 BufferedImage nok = generateImage(w / 2 + 2, h / 2 + 2, Color.RED); 91 BaseMultiResolutionImage mri = 92 new BaseMultiResolutionImage(new BufferedImage[] {nok, img}); 93 icon = new TrayIcon(img); 94 icon.setImageAutoSize(true); // just in case 95 iconMRI = new TrayIcon(mri); 96 iconMRI.setImageAutoSize(true); 97 } 98 99 private void doTest() { 100 101 if (tray.getTrayIcons().length > 0) { return; } // icons were added already 102 try { 103 tray.add(icon); 104 tray.add(iconMRI); 105 } catch (Exception e) { 106 throw new RuntimeException(e); 107 } 108 } 109 110 public void stop() { 111 112 // check for null, just in case 113 if (tray != null) { 114 tray.remove(icon); 115 tray.remove(iconMRI); 116 } |