JDK-6668442 : transparency using JNA doesn't work
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u10
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-02-27
  • Updated: 2011-02-16
  • Resolved: 2008-03-25
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.
JDK 6
6u10 b20Fixed
Related Reports
Relates :  
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
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(); + } } }
07-03-2008

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.
03-03-2008