diff --git a/src/mibewjava/org.mibew.notifier/.classpath b/src/mibewjava/org.mibew.notifier/.classpath new file mode 100644 index 00000000..23c0a51c --- /dev/null +++ b/src/mibewjava/org.mibew.notifier/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/mibewjava/org.mibew.notifier/.project b/src/mibewjava/org.mibew.notifier/.project new file mode 100644 index 00000000..4a130331 --- /dev/null +++ b/src/mibewjava/org.mibew.notifier/.project @@ -0,0 +1,17 @@ + + + org.mibew.notifier + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/src/mibewjava/org.mibew.notifier/src/org/mibew/notifier/NotifyApp.java b/src/mibewjava/org.mibew.notifier/src/org/mibew/notifier/NotifyApp.java new file mode 100644 index 00000000..142e0526 --- /dev/null +++ b/src/mibewjava/org.mibew.notifier/src/org/mibew/notifier/NotifyApp.java @@ -0,0 +1,11 @@ +package org.mibew.notifier; + +public class NotifyApp { + + public static void main(String[] args) { + TrayNotifier tn = new TrayNotifier(); + tn.init(); + + + } +} diff --git a/src/mibewjava/org.mibew.notifier/src/org/mibew/notifier/TrayNotifier.java b/src/mibewjava/org.mibew.notifier/src/org/mibew/notifier/TrayNotifier.java new file mode 100644 index 00000000..1548744b --- /dev/null +++ b/src/mibewjava/org.mibew.notifier/src/org/mibew/notifier/TrayNotifier.java @@ -0,0 +1,56 @@ +package org.mibew.notifier; + +import java.awt.AWTException; +import java.awt.Image; +import java.awt.MenuItem; +import java.awt.MenuShortcut; +import java.awt.PopupMenu; +import java.awt.SystemTray; +import java.awt.Toolkit; +import java.awt.TrayIcon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.net.URL; + +public class TrayNotifier { + + private TrayIcon trayIcon; + + public TrayNotifier() { + } + + public void init() { + if (SystemTray.isSupported()) { + + SystemTray tray = SystemTray.getSystemTray(); + URL url = this.getClass().getResource("tray.png"); + Image image = Toolkit.getDefaultToolkit().getImage(url); + + PopupMenu popup = new PopupMenu(); + MenuItem exitItem = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_X)); + exitItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }); + + popup.add(exitItem); + trayIcon = new TrayIcon(image, "Mibew Notifier", popup); + trayIcon.setImageAutoSize(true); + + try { + tray.add(trayIcon); + } catch (AWTException e) { + System.err.println("TrayIcon could not be added."); + System.exit(1); + } + } else { + System.err.println("TrayIcon could not be added."); + System.exit(1); + } + } + + public void setStatus(boolean online) { + } +} diff --git a/src/mibewjava/org.mibew.notifier/src/org/mibew/notifier/tray.png b/src/mibewjava/org.mibew.notifier/src/org/mibew/notifier/tray.png new file mode 100644 index 00000000..1e8f871a Binary files /dev/null and b/src/mibewjava/org.mibew.notifier/src/org/mibew/notifier/tray.png differ