List of usage examples for java.awt SystemTray getTrayIconSize
public Dimension getTrayIconSize()
From source file:de.darkblue.bongloader2.utils.ToolBox.java
public static BufferedImage resizeImageToTray(BufferedImage image) { SystemTray tray = SystemTray.getSystemTray(); Dimension dimension = tray.getTrayIconSize(); return resizeImage(image, dimension.width, dimension.height); }
From source file:org.languagetool.gui.Main.java
private void hideToTray() { if (!isInTray) { SystemTray tray = SystemTray.getSystemTray(); String iconPath = tray.getTrayIconSize().height > 16 ? TRAY_ICON : TRAY_SMALL_ICON; URL iconUrl = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(iconPath); Image img = Toolkit.getDefaultToolkit().getImage(iconUrl); PopupMenu popup = makePopupMenu(); try {/*w ww .j av a 2 s. c o m*/ trayIcon = new TrayIcon(img, TRAY_TOOLTIP, popup); trayIcon.addMouseListener(new TrayActionListener()); setTrayIcon(); tray.add(trayIcon); } catch (AWTException e1) { Tools.showError(e1); } } isInTray = true; frame.setVisible(false); }
From source file:org.languagetool.gui.Main.java
private void setTrayIcon() { if (trayIcon != null) { SystemTray tray = SystemTray.getSystemTray(); boolean httpServerRunning = httpServer != null && httpServer.isRunning(); boolean smallTray = tray.getTrayIconSize().height <= 16; String iconPath;// w w w . j a v a 2s. c o m if (httpServerRunning) { trayIcon.setToolTip(messages.getString("tray_tooltip_server_running")); iconPath = smallTray ? TRAY_SMALL_SERVER_ICON : TRAY_SERVER_ICON; } else { trayIcon.setToolTip(TRAY_TOOLTIP); iconPath = smallTray ? TRAY_SMALL_ICON : TRAY_ICON; } URL iconUrl = JLanguageTool.getDataBroker().getFromResourceDirAsUrl(iconPath); Image img = Toolkit.getDefaultToolkit().getImage(iconUrl); trayIcon.setImage(img); } }