add notifier project

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@731 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2010-01-17 19:03:40 +00:00
parent fcb70074bf
commit cb85159474
5 changed files with 91 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.mibew.api"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.mibew.notifier</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
package org.mibew.notifier;
public class NotifyApp {
public static void main(String[] args) {
TrayNotifier tn = new TrayNotifier();
tn.init();
}
}

View File

@ -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) {
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB