import java.awt.AWTException;
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public void notify1(String stat) throws AWTException
{
String icoPath = "D://world.png";
if (SystemTray.isSupported()) {
final SystemTray systemTray = SystemTray.getSystemTray();
final TrayIcon trayIcon = new TrayIcon(new ImageIcon(icoPath, "omt").getImage(), "Aware");
trayIcon.setImageAutoSize(true);// Autosize icon base on space
MouseAdapter mouseAdapter = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
showframe();
}
};
//ADDING APP TO SYSTEM TRAY AT SPECIFIC CONDITION
if(stat.equals("AWARE STARTED"))
{
trayIcon.addMouseListener(mouseAdapter);
systemTray.add(trayIcon);
}
try
{
//DISPLAYING MESSAGE IN SYAYTEM TRAY..
trayIcon.displayMessage("STATUS",stat,TrayIcon.MessageType.INFO);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment