i want change system tray icon image application. did 2 things -
just changed url in default program -
final trayicon trayicon = new trayicon(createimage("images/graph.png", "tray icon")); second try -
image img = toolkit.getdefaulttoolkit().getimage("images/graph.png"); final trayicon trayicon = new trayicon(img, "application name", popup); the application launches in both cases no image shown. blank placeholder. doing wrong ?
images/graph.png not valid url image located in jar. hence, guess img null on second try.
i suggest way :
//get url method class.getresource("/path/to/image.png") url url = system.class.getresource("/images/graph.png"); //use image image img = toolkit.getdefaulttoolkit().getimage(url); final trayicon trayicon = new trayicon(img, "application name", popup); you shall ensure images/ in classpath.
Comments
Post a Comment