View Single Post
  #4 (permalink)  
Old 04-24-2008, 02:33 PM
Eranga's Avatar
Eranga Eranga is offline
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,576
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Try this,

Code:
import java.awt.AWTException; import java.awt.Image; import java.awt.Menu; import java.awt.MenuItem; 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; /** * * @author Eranga Tennakoon */ public class rameshraj { TrayIcon trayIcon; /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here new rameshraj().trayIconTest(); } private void trayIconTest() { if (SystemTray.isSupported()) { try { SystemTray tray = SystemTray.getSystemTray(); ActionListener exitListener = new ActionListener(){ public void actionPerformed(ActionEvent e){ System.exit(0); } }; PopupMenu popup = new PopupMenu(); MenuItem _one = new MenuItem("Exit"); Menu _two = new Menu("Item_Two"); _one.addActionListener(exitListener); popup.add(_one); popup.add(_two); Image image = Toolkit.getDefaultToolkit().getImage("RADAR.png"); trayIcon = new TrayIcon(image, "Java", popup); trayIcon.setImageAutoSize(true); tray.add(trayIcon); } catch (AWTException e) { System.err.println("TrayIcon could not be added."); } } else { System.err.println("SystemTray is not supported."); } } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote