dynamic - Java Change tray icon -


hi trying change tray icon have in java dynamically. e.g icon grey square. when user clicks item in tray menu, grey square switch images red square.

here current code tray icon.  'public class utils {     private static image iconimage;     private static image iconimage2;     private static systemtray systray;     private static popupmenu menu;     private static menuitem item1;     private static menuitem item2;     private static menuitem item0;     private static trayicon trayicon;     private static trayicon trayicon2;     public static void loadtrayicon() {         jframe frame = new jframe("ac tray frame");          frame.setlayout(new gridlayout(1, 3));           if (systemtray.issupported()) {             systray = systemtray.getsystemtray();              iconimage  = toolkit.getdefaulttoolkit().getimage("osx_tray_icon.png");             iconimage2  = toolkit.getdefaulttoolkit().getimage("loading.gif");              menu = new popupmenu();              item0 = new menuitem("this test");             item0.setenabled(false);             item1 = new menuitem("test");             item2 = new menuitem("exit");              menu.add(item0);             menu.addseparator();             menu.add(item1);             menu.addseparator();             menu.add(item2);              item1.addactionlistener(new actionlistener() {                 public void actionperformed(actionevent e) {                     try {                         system.out.println("hi");                     } catch (ioexception e1) {                         e1.printstacktrace();                     }                 }             });              item2.addactionlistener(new actionlistener() {                 public void actionperformed(actionevent e) {                     system.exit(0);                 }             });              trayicon = new trayicon(iconimage, "test title", menu);              try {                 systray.add(trayicon);             }              catch(awtexception e) {                 system.out.println(e.getmessage());             }         }     }' 

you want use trayicon#setimage change icon displayed trayicon


Comments

Popular posts from this blog

C# random value from dictionary and tuple -

cgi - How do I interpret URLs without extension as files rather than missing directories in nginx? -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -