Java 8 TrayIcon - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 TrayIcon class.

This code example shows how to use the following methods:setImageAutoSize, setPopupMenu, setToolTip
 
		PopupMenu popupMenu = new PopupMenu();
		popupMenu.add(quitMenuItem);
 
		URL imageUrl = this.getClass().getClassLoader().getResource("images/icon.png");
		TrayIcon trayIcon = new TrayIcon(Toolkit.getDefaultToolkit().createImage(imageUrl));
		trayIcon.setImageAutoSize(true);
		trayIcon.setToolTip("WebSocketRemote");
		trayIcon.setPopupMenu(popupMenu);
 
		SystemTray systemTray = java.awt.SystemTray.getSystemTray();
		systemTray.add(trayIcon);
 
		Server server = new Server(40320);
 
		ResourceHandler resourceHandler = new ResourceHandler();
		String htmlPath = this.getClass().getClassLoader().getResource("html").toExternalForm();
		resourceHandler.setResourceBase(htmlPath);
 
		WSServlet wsServlet = new WSServlet(this);
5
CodeRank
This code example shows how to use the following methods:setImageAutoSize
		} 
 
		SystemTray sysTray = SystemTray.getSystemTray();
		URL url = Mercury.class.getResource("/res/images/icon16.png");
		Image im = Toolkit.getDefaultToolkit().getImage(url);
		icon = new TrayIcon(im, ICON_CAPTION);
		icon.setImageAutoSize(true);
		try { 
			sysTray.add(icon);
		} catch(Exception e) {
			e.printStackTrace();
			return false; 
		} 
		return true; 
	} 
 
	public static void notify(String caption, String message, boolean abbreviate) {
		if (icon == null) {
			return; 
		} 
4
CodeRank
This code example shows how to use the following methods:setPopupMenu
            } 
        } 
    } 
     
    protected void languageChanged() { 
        trayIcon.setPopupMenu(getMainMenu());
    } 
     
    /** 
     * Build a popup menu, adding callbacks to the different items. 
     * @return popup menu 
     */ 
    protected abstract PopupMenu getMainMenu();
     
    /** 
     * Get tray icon image from the desktopgui resources in the jar file. 
     * @return image used for the tray icon 
     */ 
    private Image getTrayImage() {
        URL url = getClass().getResource("/desktopgui/resources/images/logo.png");
4
CodeRank
This code example shows how to use the following methods:displayMessage
            LOGGER.debug("Ignoring notification, this notifier is not enabled"); 
 
            return false; 
        } 
 
        trayIcon.displayMessage(title, description, MESSAGE_TYPES.get(notificationType));
        return true; 
    } 
 
    @Override 
    public String getPrettyName() {
        return "System Tray"; 
    } 
 
 
    /////////////////////////////////// 
    // ActionListener implementation // 
    /////////////////////////////////// 
 
    public void actionPerformed(ActionEvent actionEvent) {
3
CodeRank
This code example shows how to use the following methods:displayMessage
		trayIcon = new TrayIcon(image, "Tray Demo", popup);
 
		ActionListener actionListener = new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.out.println("Tray actionPerformed");
				trayIcon.displayMessage("Action Event",
						"An Action Event Has Been Performed!", 
						TrayIcon.MessageType.INFO);
			} 
		}; 
 
		trayIcon.setImageAutoSize(true);
 
		trayIcon.addActionListener(actionListener);
 
		try { 
			tray.add(trayIcon);
		} catch (AWTException e) {
			System.err.println("TrayIcon could not be added.");
		} 
3
CodeRank
See Code Examples for Java 8 TrayIcon Methods: