Attempting to show progress bar icons in taskbar with Java, but all I get is a single black line -


i've attempted create progress bar images using following code:

public static void makeimage(int percent) {     bufferedimage img = new bufferedimage(100, 30, bufferedimage.type_int_argb);     graphics g = img.getgraphics();      g.setcolor(color.light_gray);     g.fillrect(0, 0, 100, 30);      (int x = 0; x < percent; x++)     {         (int y = 0; y < img.getheight(); y++)         {             img.setrgb(x, y, color.green.darker().getrgb() );         }     }      imgutility.save("/home/xxx/java/myproj/src/myproj/resources/progressbars/"             + percent + ".png", img); } 

this creates bunch of 100x30 images 1.png 100.png, this:

1.png

50.png

100.png

then, i'm trying show these images in tray, , cycle through them 1 one, show illusion of animated progress bar (in actual usage, want use these images show progress of task being done):

    tray tray = display.getdefault().getsystemtray();     trayitem trayitem = new trayitem(tray, swt.none);      (int p = 1; p <= 100; p++)     {         image icon = iconloader.load("progressbars/" + p + ".png");         system.out.println(icon.getbounds()); //always outputs         //rectangle {0, 0, 100, 30}, showing 100x30 images loaded         //correctly.         trayitem.setimage(icon);         try         {             thread.sleep(1000);         }         catch (exception e)         {             e.printstacktrace();             system.exit(0);         }     } 

however, when run code, instead of seeing full image in taskbar, see single vertical black/dark green line.

i on linux mint.

what doing wrong..?

in context code manipulating tray icon running? possible blocking ui thread painting icon? i'm not sure, may need on separate thread.


Comments