Create your tray icon
Posted by
neo
on Tuesday, June 16, 2009
design by Free CSS Templates, blogger design by TeknoMobi
import java.awt.AWTException;
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Test {
static Image image = Toolkit.getDefaultToolkit().getImage("c:/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.");
}
}
}
}
Copyright (c) 2009 All About Java. All rights reserved. Design by Free CSS Templates Blogspot Templates Created by TeknoMobi.
0 comments:
Post a Comment