swing - Java - TrayIcon messages not displaying on Windows XP, Vista -
i'm writing application utilizes java's trayicon
class, can't seem display messages on windows xp/vista. known issue or there i'm missing? (messages appear should on windows 7)
code:
public class systray { public static void main(string[] args) throws exception { trayicon icon = new trayicon(getimage()); icon.addactionlistener(new actionlistener() { public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "good"); } }); systemtray.getsystemtray().add(icon); icon.displaymessage("attention", "please click here", trayicon.messagetype.warning); } private static image getimage() throws headlessexception { icon defaulticon = metaliconfactory.gettreeharddriveicon(); image img = new bufferedimage(defaulticon.geticonwidth(), defaulticon.geticonheight(), bufferedimage.type_4byte_abgr); defaulticon.painticon(new panel(), img.getgraphics(), 0, 0); return img; } }
edit: computers both using latest version of java
edit ii: results of tests on various computers:
- windows xp, j7_25 (1.7.0_25-b16): works
- windows 7, j7_25 (1.7.0_25-b17): works
- windows xp, j7_25 (1.7.0_25-b17): not work
see whats happened (java6_022 , java7_21, tested on both jdks)
winxp - ->
win8 - ->
from code
import java.awt.awtexception; import java.awt.eventqueue; import java.awt.headlessexception; import java.awt.image; import java.awt.systemtray; import java.awt.trayicon; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.image.bufferedimage; import javax.swing.icon; import javax.swing.joptionpane; import javax.swing.jpanel; import javax.swing.plaf.metal.metaliconfactory; public class systray { public systray() { trayicon icon = new trayicon(getimage()); icon.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent e) { joptionpane.showmessagedialog(null, "good"); } }); try { systemtray.getsystemtray().add(icon); } catch (awtexception ex) { } icon.displaymessage("attn","click here",trayicon.messagetype.warning); } private image getimage() throws headlessexception { icon defaulticon = metaliconfactory.gettreeharddriveicon(); image img = new bufferedimage(defaulticon.geticonwidth(), defaulticon.geticonheight(), bufferedimage.type_4byte_abgr); defaulticon.painticon(new jpanel(), img.getgraphics(), 0, 0); return img; } public static void main(string[] args) { eventqueue.invokelater(new runnable() { @override public void run() { systray systray = new systray(); } }); } }
Comments
Post a Comment