trayIcon.setImageAutoSize(true);
trayIcon.setImageAutoSize(true); trayIcon.addActionListener(actionListener); trayIcon.addMouseListener(new MouseListener() {
trayIcon = new TrayIcon(mainIcon); trayIcon.setToolTip(mainFrame.getTitle()); trayIcon.setImageAutoSize(true); trayIcon.setPopupMenu(trayMenu); SystemTray.getSystemTray().add(trayIcon);
popup.add(defaultItem); trayIcon=new TrayIcon(image, "SystemTray Demo", popup); trayIcon.setImageAutoSize(true); }else{ System.out.println("system tray not supported");
public class Main { static Image image = Toolkit.getDefaultToolkit().getImage("images/tray.gif"); static TrayIcon trayIcon = new TrayIcon(image, "Tester2"); public static void main(String[] a) throws Exception { if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); trayIcon.setImageAutoSize(true); trayIcon.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("In here"); trayIcon.displayMessage("Tester!", "Some action performed", TrayIcon.MessageType.INFO); } }); try { tray.add(trayIcon); } catch (AWTException e) { System.err.println("TrayIcon could not be added."); } } } }
/** * @param mainFrame The MainFrame class used for closing actions from TrayPopup. */ public MainWindowListener(final MainFrame mainFrame) { useTray = (SystemTray.isSupported() && Boolean.parseBoolean(Configuration.INSTANCE.get("application.tray.use"))); if (useTray) { final TrayPopup trayPopup = new TrayPopup(mainFrame); final Image iconImage = Toolkit.getDefaultToolkit().getImage(getClass(). getResource(Configuration.INSTANCE.get("application.icon.path"))); trayIcon = new TrayIcon(iconImage); trayIcon.setImageAutoSize(true); trayIcon.setPopupMenu(trayPopup.get()); } }
@PostConstruct public void initialize() { bus.subscribe(new UpdateTimeOnTray(), TimerTick.class); bus.subscribe(new ShowTomatoIconWhenTimerStops(), TimerStopped.class); bus.subscribe(new RemoveTimeFromTray(), TimeOnTrayConfigChanged.class); trayIcon = new TrayIcon(icons.tomato()); trayIcon.addMouseListener(new TrayListener()); trayIcon.setImageAutoSize(true); }
trayIcon.setImageAutoSize(true);
/** * Add the tray icon to the system tray and start everything up. */ public synchronized void startManager() throws AWTException { if (!SystemTray.isSupported()) throw new AWTException("SystemTray not supported"); tray = SystemTray.getSystemTray(); // Windows typically has tooltips; Linux (at least Ubuntu) doesn't String tooltip = SystemVersion.isWindows() ? _t("I2P: Right-click for menu") : null; TrayIcon ti; if (_useSwing) ti = getSwingTrayIcon(tooltip); else ti = getAWTTrayIcon(tooltip); ti.setImageAutoSize(true); //Resize image to fit the system tray tray.add(ti); trayIcon = ti; }
public static void sendNotification(String title, String subtitle, String pathToIcon) { SystemTray mainTray = SystemTray.getSystemTray(); Image trayIconImage = Toolkit.getDefaultToolkit().getImage(pathToIcon); TrayIcon mainTrayIcon = new TrayIcon(trayIconImage); mainTrayIcon.setImageAutoSize(true); try { mainTray.add(mainTrayIcon); mainTrayIcon.displayMessage(title, subtitle, TrayIcon.MessageType.NONE); } catch (Exception e) { e.printStackTrace(); } }
flashedImage = ImageManagerImpl.instance.getAppFlashedImage(); trayIcon = new TrayIcon(mainImage); trayIcon.setImageAutoSize(true);
public static void setUpSystemTray () { trayMenu = new TrayMenu(); SystemTray tray = SystemTray.getSystemTray(); TrayIcon trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().getImage(instance.getClass().getResource("/image/logo_ftb.png"))); trayIcon.setPopupMenu(trayMenu); trayIcon.setToolTip(Constants.name); trayIcon.setImageAutoSize(true); try { tray.add(trayIcon); } catch (AWTException e) { e.printStackTrace(); } }
import java.awt.*; import java.awt.event.*; import java.awt.image.*; public class AWTScratch { public static void main(String[] args) { BufferedImage im = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB); TrayIcon ti = new TrayIcon(im, "Multiline\nmulti"); ti.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); ti.setImageAutoSize(true); if (SystemTray.isSupported()){ SystemTray st=SystemTray.getSystemTray(); try { st.add(ti); } catch (AWTException e1) { e1.printStackTrace(); } } } }
private void createTrayIcon() { PopupMenu trayMenu = new PopupMenu(); MenuItem exit = new MenuItem("Exit"); exit.addActionListener(e -> { exit(); }); MenuItem restore = new MenuItem("Restore default location"); restore.addActionListener(e -> { FramesManager.INSTANCE.restoreDefaultLocation(); }); trayMenu.add(restore); trayMenu.add(exit); BufferedImage icon = null; try { icon = ImageIO.read(getClass().getClassLoader().getResource("app/app-icon.png")); } catch (IOException e) { e.printStackTrace(); } this.trayIcon = new TrayIcon(icon, "MercuryTrade", trayMenu); this.trayIcon.setImageAutoSize(true); SystemTray tray = SystemTray.getSystemTray(); try { tray.add(this.trayIcon); } catch (AWTException e) { e.printStackTrace(); } }
private static void initSystemTray() { // add system tray icon with popup menu if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); PopupMenu menu = new PopupMenu(); MenuItem exitItem = new MenuItem(Resources.strings().get("menu_exit")); exitItem.addActionListener(a -> System.exit(0)); menu.add(exitItem); trayIcon = new TrayIcon(Resources.images().get("litiengine-icon.png"), Game.info().toString(), menu); trayIcon.setImageAutoSize(true); try { tray.add(trayIcon); } catch (AWTException e) { log.log(Level.SEVERE, e.getLocalizedMessage(), e); } } } }
@Override public Notifier init() { if (icon != null) { return this; } if (!SystemTray.isSupported()) { skipNotifications = true; LOGGER.warn("SystemTray is not supported, skipping notifications..."); return this; } icon = new TrayIcon(createImage(application.icon().toByteArray()), application.name()); icon.setImageAutoSize(true); try { SystemTray.getSystemTray().add(icon); } catch (AWTException e) { throw new SystemTrayNotificationException("Error initializing SystemTray Icon.", e); } return this; }
@Override public Notifier init() { if (icon != null) { return this; } if (!SystemTray.isSupported()) { skipNotifications = true; LOGGER.warn("SystemTray is not supported, skipping notifications..."); return this; } icon = new TrayIcon(createImage(application.icon().toByteArray()), application.name()); icon.setImageAutoSize(true); try { SystemTray.getSystemTray().add(icon); } catch (AWTException e) { throw new SystemTrayNotificationException("Error initializing SystemTray Icon.", e); } return this; }
trayIcon.setImageAutoSize(true);
/** * This tries to create the system tray menu. * * @throws Exception */ private static void trySystemTrayIntegration() throws Exception { if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); TrayIcon trayIcon = new TrayIcon(Utils.getImage("/assets/image/Icon.png")); trayIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { TRAY_MENU.setInvoker(TRAY_MENU); TRAY_MENU.setLocation(e.getX(), e.getY()); TRAY_MENU.setVisible(true); } } }); trayIcon.setToolTip(Constants.LAUNCHER_NAME); trayIcon.setImageAutoSize(true); tray.add(trayIcon); } }
public TrayIconManager(Image image) { if (SystemTray.isSupported()) { tray = SystemTray.getSystemTray(); popup = new PopupMenu(); MenuItem showItem = new MenuItem("Show"); showItem.setActionCommand("show"); popup.add(showItem); MenuItem exitItem = new MenuItem("Exit"); exitItem.setActionCommand("exit"); popup.add(exitItem); trayIcon = new TrayIcon(image, "Chatty"); trayIcon.setImageAutoSize(true); trayIcon.setPopupMenu(popup); } else { tray = null; trayIcon = null; popup = null; } }