java.awt.SystemTray.getSystemTray().add(new java.awt.TrayIcon(java.awt.Toolkit.getDefaultToolkit().getImage("foo.png")));
trayIcon.addActionListener(actionListener); try { tray.add(trayIcon); start(); } catch (AWTException ex) {
systemTray.add(trayIcon);
tray.add(trayIcon);
trayIcon.setImageAutoSize(true); trayIcon.setPopupMenu(trayMenu); SystemTray.getSystemTray().add(trayIcon); trayIcon.addMouseListener(new MouseAdapter() { @Override
tray.add(trayIcon); } catch (AWTException e) { System.err.println(e);
tray.add(trayIcon); } catch (AWTException e) { System.err.println(e);
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."); } } } }
@Override public void run() { SystemTray tray = SystemTray.getSystemTray(); try { tray.add(trayIcon); } catch (AWTException e) { throw new RuntimeException(e); } boolean firstRun = config.asBoolean("firstRun", true); if(firstRun) { showWelcomeMessage(trayIcon); config.set("firstRun", false); } }
tray.add(trayIcon); frame.dispose(); } catch (AWTException ex) {
systemTray.add(trayIcon); }catch(AWTException awtException){ awtException.printStackTrace();
/** * 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; }
if (SystemTray.isSupported()) { SystemTray tray = SystemTray.getSystemTray(); Image image = ...; trayIcon = new TrayIcon(image, "Tray Demo"); try { tray.add(trayIcon); } catch (AWTException e) { System.err.println(e); } }
popup.add(item); try { tray.add(trayIcon); } catch (AWTException e) { System.err.println("Can't add to tray");
SystemTray tray = SystemTray.getSystemTray(); Image image = Toolkit.getDefaultToolkit().getImage("tray.gif"); TrayIcon trayIcon = new TrayIcon(image, "Tray Demo"); tray.add(trayIcon); trayIcon.displayMessage("Hello, World", "notification demo", MessageType.INFO);
frame.setResizable(false); frame.setVisible(true); tray.add(trayIcon); } catch (AWTException e) { System.out.println("TrayIcon could not be added.");
final PopupMenu popup = new PopupMenu(); final TrayIcon trayIcon = new TrayIcon(createImage("images/bulb.gif", "tray icon")); final SystemTray tray = SystemTray.getSystemTray(); // Populate popup menu trayIcon.setPopupMenu(popup); try { tray.add(trayIcon); } catch (AWTException e) { System.out.println("TrayIcon could not be added."); }
tray.add(trayIcon); } catch (AWTException e) { log.error("TrayIcon could not be added: ", e);
private static void createGui() { JXTrayIcon tray = new JXTrayIcon(createImage()); tray.setJPopuMenu(createJPopupMenu()); try { SystemTray.getSystemTray().add(tray); } catch (AWTException e) { e.printStackTrace(); } }