Created
July 12, 2010 14:20
-
-
Save alissonsales/472516 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.AWTException; | |
import java.awt.MenuItem; | |
import java.awt.PopupMenu; | |
import java.awt.SystemTray; | |
import java.awt.TrayIcon; | |
import java.awt.event.MouseAdapter; | |
import java.awt.event.MouseEvent; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.imageio.ImageIO; | |
import javax.swing.JOptionPane | |
public class Main { | |
public static void main(String[] args) throws AWTException, IOException { | |
if (SystemTray.isSupported()) { | |
JOptionPane.showMessageDialog(null, "Eu suporto SystemTray "); | |
SystemTray tray = SystemTray.getSystemTray(); | |
tray.add(new MyTrayIcon()); | |
} | |
} | |
} | |
class MyTrayIcon extends TrayIcon { | |
public MyTrayIcon() throws IOException { | |
super(ImageIO.read(new File("img.jpg")), "TrayIcon "); | |
setImageAutoSize(true); | |
final PopupMenu popup = new PopupMenu("popup"); | |
setPopupMenu(popup); | |
getPopupMenu().add(new MenuItem("menuItem")); | |
addMouseListener(new MouseAdapter() { | |
@Override | |
public void mouseClicked(MouseEvent e) { | |
displayMessage("Finished downloading", "Your Java application has finished downloading", TrayIcon.MessageType.INFO); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment