United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6668442 transparency using JNA doesn't work
JDK-6668442 : transparency using JNA doesn't work

Details
Type:
Bug
Submit Date:
2008-02-27
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2008-03-25
Component:
client-libs
OS:
windows_xp
Sub-Component:
java.awt
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u10
Fixed Versions:
6u10 (b20)

Related Reports
Relates:

Sub Tasks

Description
Tranparency using JNA libraries stops to work. It works on JDK 1.6u3 and prior versions
The test case to reproduce the problem:

1) https://jna.dev.java.net/ -> 'documents and files' -> 'latest' -> download jna.jar + examples.jar

2) run the following test:

import javax.swing.JFrame;
import com.sun.jna.examples.WindowUtils;
public class test{
   public static final void main(String args[]){
   JFrame fr = new JFrame();
   fr.setBounds(100,100,200,200);
   WindowUtils.setWindowTransparent(fr, true);
   fr.setVisible(true);
   }
}

                                    

Comments
EVALUATION

Seems to be related to the fact that since 6.0u10b12 the AWT uses the Layered Windows machinery. Exactly this machinery is used at the WindowUtils of JNA to enable the trasnparency effect. When both the AWT and the WindowUtils use the same Win API functions, there may happen a kind of a threadrace, when the WindowUtils enables the transparency, and later the AWT disables it. It seems we should follow the same approach as we did at CR 6661455: if an effect (opacity, or translucency) has not been enabled, we don't need to initialize it at the native level.
                                     
2008-03-03
SUGGESTED FIX

--- old/src/share/classes/java/awt/Window.java	2008-03-07 17:52:45.000000000 +0300
+++ new/src/share/classes/java/awt/Window.java	2008-03-07 17:52:45.000000000 +0300
@@ -648,8 +648,12 @@
             if (shape != null) {
                 applyShape();
             }
-            applyOpaque();
-            applyOpacity();
+            if (!opaque) {
+                applyOpaque();
+            }
+            if (opacity < 1.0f) {
+                applyOpacity();
+            }
         }
     }
                                     
2008-03-07



Hardware and Software, Engineered to Work Together