JDK-6267936 : PIT: Changing the image does not clear the previous image on Sol10-JDS, System Tray
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2005-05-10
  • Updated: 2011-01-19
  • Resolved: 2005-08-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6 b47Fixed
Related Reports
Relates :  
I am creating a tray icon with a GIF image and adding it to the system tray. The image appears properly. I am changing this image to a new GIF image where the new image is transparent (background is seen through). When I call TrayIcon.setImage(), the new image is drawn on top of the old image and old image is actually not erased properly. Since the new image is a transparent image, old image is seen through. So the whole tray icon gets messed up. Removing and adding the icon again solves the problem. 

This is noticed only on Solaris10-JDS and not reproducible on Win32. On Win32, the background is cleared properly before drawing the new image. This is seen on the following PIT build: 

java version "1.6.0-awt.pit-int-awt-blade"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-awt.pit-int-awt-blade-df153228_06_May_2005_08_56-b00)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b35, mixed mode)

I have attached a sample test and few images. Execute the sample test on Sol10-JDS as follows - 
"java SystemTrayTest".
 You would see a default image on the tray icon. You would see a frame. Click 'Set Image' button. A file dialog would appear. Select 'fight.gif' image (attached to the bug report). If fight.gif is drawn on top of the existing image, the bug is reproduced.
###@###.### 2005-05-10 14:09:54 GMT

This is well noticed when using any of the transparent animated gifs. The background is not cleared when switching over from one frame to another frame in the animated image and hence all the frames are drawn one above the other (use animdog.gif).

###@###.### 2005-05-10 14:34:09 GMT

SUGGESTED FIX --- XTrayIconPeer.java Wed Jul 13 14:52:36 2005 *************** *** 400,406 **** } public void paint(Graphics g) { if (g != null) { ! g.drawImage(image, 0, 0, curW, curH, observer); } } public void setObserver(ImageObserver observer) { --- 399,412 ---- } public void paint(Graphics g) { if (g != null) { ! BufferedImage bufImage = new BufferedImage(curW, curH, BufferedImage.TYPE_INT_ARGB); ! Graphics2D gr = bufImage.createGraphics(); ! gr.setColor(getBackground()); ! gr.fillRect(0, 0, curW, curH); ! gr.drawImage(image, 0, 0, curW, curH, observer); ! gr.dispose(); ! ! g.drawImage(bufImage, 0, 0, curW, curH, null); } } public void setObserver(ImageObserver observer) { ###@###.### 2005-07-13 10:54:58 GMT

EVALUATION Better to resolve in Mustang. ###@###.### 2005-06-24 14:09:36 GMT It seems that the bug can be easily reproduced on any linux/solaris desktop, that supports Tray. At least, it is reproducible on RHAS 3.0 w/ KDE and GNOME. ###@###.### 2005-07-12 12:35:47 GMT The problem appears when using transparent images only. When a new image is set for tray icon (or the next frame of animated image is ready), all the transparent pixels are simply ignored. We should clear the icon before drawing a new image or a next frame of animated image. ###@###.### 2005-07-13 10:54:57 GMT