java.awt.TrayIcon Java Examples
The following examples show how to use
java.awt.TrayIcon.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WTrayIconPeer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@Override public synchronized void showPopupMenu(final int x, final int y) { if (isDisposed()) return; SunToolkit.executeOnEventHandlerThread(target, new Runnable() { @Override public void run() { PopupMenu newPopup = ((TrayIcon)target).getPopupMenu(); if (popup != newPopup) { if (popup != null) { popupParent.remove(popup); } if (newPopup != null) { popupParent.add(newPopup); } popup = newPopup; } if (popup != null) { ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y)); } } }); }
Example #2
Source File: WTrayIconPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public synchronized void showPopupMenu(final int x, final int y) { if (isDisposed()) return; SunToolkit.executeOnEventHandlerThread(target, new Runnable() { @Override public void run() { PopupMenu newPopup = ((TrayIcon)target).getPopupMenu(); if (popup != newPopup) { if (popup != null) { popupParent.remove(popup); } if (newPopup != null) { popupParent.add(newPopup); } popup = newPopup; } if (popup != null) { ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y)); } } }); }
Example #3
Source File: WTrayIconPeer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
synchronized void updateNativeImage(Image image) { if (isDisposed()) return; boolean autosize = ((TrayIcon)target).isImageAutoSize(); BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D gr = bufImage.createGraphics(); if (gr != null) { try { gr.setPaintMode(); gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)), (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer); createNativeImage(bufImage); updateNativeIcon(!firstUpdate); if (firstUpdate) firstUpdate = false; } finally { gr.dispose(); } } }
Example #4
Source File: WTrayIconPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public synchronized void showPopupMenu(final int x, final int y) { if (isDisposed()) return; SunToolkit.executeOnEventHandlerThread(target, new Runnable() { @Override public void run() { PopupMenu newPopup = ((TrayIcon)target).getPopupMenu(); if (popup != newPopup) { if (popup != null) { popupParent.remove(popup); } if (newPopup != null) { popupParent.add(newPopup); } popup = newPopup; } if (popup != null) { ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y)); } } }); }
Example #5
Source File: SysTray.java From visualvm with GNU General Public License v2.0 | 6 votes |
private TrayIcon createTrayIcon() { Image image = createTrayImage(); String tooltip = createTrayTooltip(); trayPopup = createTrayPopup(); TrayIcon icon = new TrayIcon(image, tooltip, trayPopup); icon.setImageAutoSize(true); icon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (trayPopup.isEnabled()) toggleWindowVisibility(); } }); } }); return icon; }
Example #6
Source File: WTrayIconPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public synchronized void showPopupMenu(final int x, final int y) { if (isDisposed()) return; SunToolkit.executeOnEventHandlerThread(target, new Runnable() { @Override public void run() { PopupMenu newPopup = ((TrayIcon)target).getPopupMenu(); if (popup != newPopup) { if (popup != null) { popupParent.remove(popup); } if (newPopup != null) { popupParent.add(newPopup); } popup = newPopup; } if (popup != null) { ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y)); } } }); }
Example #7
Source File: WTrayIconPeer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public synchronized void showPopupMenu(final int x, final int y) { if (isDisposed()) return; SunToolkit.executeOnEventHandlerThread(target, new Runnable() { public void run() { PopupMenu newPopup = ((TrayIcon)target).getPopupMenu(); if (popup != newPopup) { if (popup != null) { popupParent.remove(popup); } if (newPopup != null) { popupParent.add(newPopup); } popup = newPopup; } if (popup != null) { ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y)); } } }); }
Example #8
Source File: WTrayIconPeer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
synchronized void updateNativeImage(Image image) { if (isDisposed()) return; boolean autosize = ((TrayIcon)target).isImageAutoSize(); BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D gr = bufImage.createGraphics(); if (gr != null) { try { gr.setPaintMode(); gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)), (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer); createNativeImage(bufImage); updateNativeIcon(!firstUpdate); if (firstUpdate) firstUpdate = false; } finally { gr.dispose(); } } }
Example #9
Source File: NeembuuUploader.java From neembuu-uploader with GNU General Public License v3.0 | 6 votes |
private void setUpTrayIcon() { if (SystemTray.isSupported()) { //trayIcon.setImageAutoSize(true); It renders the icon very poorly. //So we render the icon ourselves with smooth settings. { Dimension d = SystemTray.getSystemTray().getTrayIconSize(); trayIcon = new TrayIcon(getIconImage().getScaledInstance(d.width, d.height, Image.SCALE_SMOOTH)); } //trayIcon = new TrayIcon(getIconImage()); //trayIcon.setImageAutoSize(true); trayIcon.setToolTip(Translation.T().trayIconToolTip()); trayIcon.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NULogger.getLogger().info("System tray double clicked"); setExtendedState(JFrame.NORMAL); setVisible(true); repaint(); SystemTray.getSystemTray().remove(trayIcon); } }); } }
Example #10
Source File: WTrayIconPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
synchronized void updateNativeImage(Image image) { if (isDisposed()) return; boolean autosize = ((TrayIcon)target).isImageAutoSize(); BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D gr = bufImage.createGraphics(); if (gr != null) { try { gr.setPaintMode(); gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)), (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer); createNativeImage(bufImage); updateNativeIcon(!firstUpdate); if (firstUpdate) firstUpdate = false; } finally { gr.dispose(); } } }
Example #11
Source File: WTrayIconPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public synchronized void showPopupMenu(final int x, final int y) { if (isDisposed()) return; SunToolkit.executeOnEventHandlerThread(target, new Runnable() { @Override public void run() { PopupMenu newPopup = ((TrayIcon)target).getPopupMenu(); if (popup != newPopup) { if (popup != null) { popupParent.remove(popup); } if (newPopup != null) { popupParent.add(newPopup); } popup = newPopup; } if (popup != null) { ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y)); } } }); }
Example #12
Source File: WTrayIconPeer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
synchronized void updateNativeImage(Image image) { if (isDisposed()) return; boolean autosize = ((TrayIcon)target).isImageAutoSize(); BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D gr = bufImage.createGraphics(); if (gr != null) { try { gr.setPaintMode(); gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)), (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer); createNativeImage(bufImage); updateNativeIcon(!firstUpdate); if (firstUpdate) firstUpdate = false; } finally { gr.dispose(); } } }
Example #13
Source File: WTrayIconPeer.java From hottub with GNU General Public License v2.0 | 6 votes |
synchronized void updateNativeImage(Image image) { if (isDisposed()) return; boolean autosize = ((TrayIcon)target).isImageAutoSize(); BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D gr = bufImage.createGraphics(); if (gr != null) { try { gr.setPaintMode(); gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)), (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer); createNativeImage(bufImage); updateNativeIcon(!firstUpdate); if (firstUpdate) firstUpdate = false; } finally { gr.dispose(); } } }
Example #14
Source File: Notifier.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void sendNotification( final String title, final String message, final TrayIcon.MessageType type) { final String escapedTitle = SHELL_ESCAPE.escape(title); final String escapedMessage = SHELL_ESCAPE.escape(message); switch (OSType.getOSType()) { case Linux: sendLinuxNotification(escapedTitle, escapedMessage, type); break; case MacOS: sendMacNotification(escapedTitle, escapedMessage); break; default: sendTrayNotification(title, message, type); } }
Example #15
Source File: WTrayIconPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public synchronized void showPopupMenu(final int x, final int y) { if (isDisposed()) return; SunToolkit.executeOnEventHandlerThread(target, new Runnable() { @Override public void run() { PopupMenu newPopup = ((TrayIcon)target).getPopupMenu(); if (popup != newPopup) { if (popup != null) { popupParent.remove(popup); } if (newPopup != null) { popupParent.add(newPopup); } popup = newPopup; } if (popup != null) { ((WPopupMenuPeer)popup.getPeer()).show(popupParent, new Point(x, y)); } } }); }
Example #16
Source File: WTrayIconPeer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
synchronized void updateNativeImage(Image image) { if (isDisposed()) return; boolean autosize = ((TrayIcon)target).isImageAutoSize(); BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D gr = bufImage.createGraphics(); if (gr != null) { try { gr.setPaintMode(); gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)), (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer); createNativeImage(bufImage); updateNativeIcon(!firstUpdate); if (firstUpdate) firstUpdate = false; } finally { gr.dispose(); } } }
Example #17
Source File: DownApplication.java From proxyee-down with Apache License 2.0 | 6 votes |
private void initTray() throws AWTException { if (SystemTray.isSupported()) { // 获得系统托盘对象 SystemTray systemTray = SystemTray.getSystemTray(); // 获取图片所在的URL URL url = Thread.currentThread().getContextClassLoader().getResource(ICON_PATH); // 为系统托盘加托盘图标 Image trayImage = Toolkit.getDefaultToolkit().getImage(url); Dimension trayIconSize = systemTray.getTrayIconSize(); trayImage = trayImage.getScaledInstance(trayIconSize.width, trayIconSize.height, Image.SCALE_SMOOTH); trayIcon = new TrayIcon(trayImage, "Proxyee Down"); systemTray.add(trayIcon); loadPopupMenu(); //双击事件监听 trayIcon.addActionListener(event -> Platform.runLater(() -> loadUri(null, true))); } }
Example #18
Source File: WTrayIconPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
synchronized void updateNativeImage(Image image) { if (isDisposed()) return; boolean autosize = ((TrayIcon)target).isImageAutoSize(); BufferedImage bufImage = new BufferedImage(TRAY_ICON_WIDTH, TRAY_ICON_HEIGHT, BufferedImage.TYPE_INT_ARGB); Graphics2D gr = bufImage.createGraphics(); if (gr != null) { try { gr.setPaintMode(); gr.drawImage(image, 0, 0, (autosize ? TRAY_ICON_WIDTH : image.getWidth(observer)), (autosize ? TRAY_ICON_HEIGHT : image.getHeight(observer)), observer); createNativeImage(bufImage); updateNativeIcon(!firstUpdate); if (firstUpdate) firstUpdate = false; } finally { gr.dispose(); } } }
Example #19
Source File: WTrayIconPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public synchronized void showPopupMenu(final int x, final int y) { if (isDisposed()) return; SunToolkit.executeOnEventHandlerThread(target, () -> { PopupMenu newPopup = ((TrayIcon)target).getPopupMenu(); if (popup != newPopup) { if (popup != null) { popupParent.remove(popup); } if (newPopup != null) { popupParent.add(newPopup); } popup = newPopup; } if (popup != null) { WPopupMenuPeer peer = AWTAccessor.getMenuComponentAccessor() .getPeer(popup); peer.show(popupParent, new Point(x, y)); } }); }
Example #20
Source File: Manager.java From ramus with GNU General Public License v3.0 | 5 votes |
private void start(String[] args) { SystemTray tray = SystemTray.getSystemTray(); TrayIcon icon = new TrayIcon(Toolkit.getDefaultToolkit().createImage( getClass().getResource( "/com/ramussoft/gui/server/application.png")), getString("Server") + " " + Metadata.getApplicationName(), createPopupMenu()); icon.setImageAutoSize(true); try { tray.add(icon); } catch (AWTException e) { e.printStackTrace(); } }
Example #21
Source File: WTrayIconPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void updateImage() { Image image = ((TrayIcon)target).getImage(); if (image != null) { updateNativeImage(image); } }
Example #22
Source File: WTrayIconPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) { if (image != ((TrayIcon)target).getImage() || // if the image has been changed isDisposed()) { return false; } if ((flags & (ImageObserver.FRAMEBITS | ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT)) != 0) { updateNativeImage(image); } return (flags & ImageObserver.ALLBITS) == 0; }
Example #23
Source File: IdleNotifierPlugin.java From plugins with GNU General Public License v3.0 | 5 votes |
@Subscribe private void onPlayerSpawned(PlayerSpawned event) { final Player p = event.getPlayer(); if (config.notifyPkers() && p != null && p != client.getLocalPlayer() && PvPUtil.isAttackable(client, p) && !client.isFriended(p.getName(), false) && !friendChatManager.isMember(p.getName())) { String playerName = p.getName(); int combat = p.getCombatLevel(); notifier.notify("PK'er warning! A level " + combat + " player named " + playerName + " appeared!", TrayIcon.MessageType.WARNING); } }
Example #24
Source File: WTrayIconPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void updateImage() { Image image = ((TrayIcon)target).getImage(); if (image != null) { updateNativeImage(image); } }
Example #25
Source File: PopupMenuLeakTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void removeIcon() { TrayIcon icon = iconWeakReference.get().get(); if (icon == null) { throw new RuntimeException("Failed: TrayIcon collected too early"); } SystemTray.getSystemTray().remove(icon); }
Example #26
Source File: PopupMenuLeakTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void createSystemTrayIcon() { final TrayIcon trayIcon = new TrayIcon(createTrayIconImage()); trayIcon.setImageAutoSize(true); try { // Add tray icon to system tray *before* adding popup menu to demonstrate buggy behaviour trayIcon.setPopupMenu(createTrayIconPopupMenu()); SystemTray.getSystemTray().add(trayIcon); iconWeakReference.set(new WeakReference<>(trayIcon)); popupWeakReference.set(new WeakReference<>(trayIcon.getPopupMenu())); } catch (final AWTException awte) { awte.printStackTrace(); } }
Example #27
Source File: WTrayIconPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
synchronized void updateNativeImage(Image image) { if (isDisposed()) return; boolean autosize = ((TrayIcon)target).isImageAutoSize(); AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment(). getDefaultScreenDevice().getDefaultConfiguration(). getDefaultTransform(); int w = Region.clipScale(TRAY_ICON_WIDTH, tx.getScaleX()); int h = Region.clipScale(TRAY_ICON_HEIGHT, tx.getScaleY()); int imgWidth = Region.clipScale(image.getWidth(observer), tx.getScaleX()); int imgHeight = Region.clipScale(image.getHeight(observer), tx.getScaleY()); BufferedImage bufImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D gr = bufImage.createGraphics(); if (gr != null) { try { gr.setPaintMode(); gr.drawImage(image, 0, 0, (autosize ? w : imgWidth), (autosize ? h : imgHeight), observer); createNativeImage(bufImage); updateNativeIcon(!firstUpdate); if (firstUpdate) firstUpdate = false; } finally { gr.dispose(); } } }
Example #28
Source File: WTrayIconPeer.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public void updateImage() { Image image = ((TrayIcon)target).getImage(); if (image != null) { updateNativeImage(image); } }
Example #29
Source File: WTrayIconPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) { if (image != ((TrayIcon)target).getImage() || // if the image has been changed isDisposed()) { return false; } if ((flags & (ImageObserver.FRAMEBITS | ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT)) != 0) { updateNativeImage(image); } return (flags & ImageObserver.ALLBITS) == 0; }
Example #30
Source File: WTrayIconPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) { if (image != ((TrayIcon)target).getImage() || // if the image has been changed isDisposed()) { return false; } if ((flags & (ImageObserver.FRAMEBITS | ImageObserver.ALLBITS | ImageObserver.WIDTH | ImageObserver.HEIGHT)) != 0) { updateNativeImage(image); } return (flags & ImageObserver.ALLBITS) == 0; }