Translucent and shaped windows in JDK 7
The latest weekly drop of JDK 7 (b57) has finally exposed the functionality of translucent and shaped windows as publicly supported APIs on the java.awt.Window class. Bug 6802853 has tracked the progress of exposing these APIs previously available in 6u10+ in the internal com.sun.awt.AWTUtilities class, and it’s time to update the examples to use the new public APIs.
To recap, here are the previous entries that used the AWTUtilities class:
- Translucent and shaped windows in core Java talked about the AWTUtilities class in 6u10 and support for modern top-level windows effects.
- Soft clipping and per-pixel translucency for Swing windows explored the translucent effects on top-level windows.
- More tricks with translucent Swing windows followed up with the different effects achievable with the new translucent window support.
All the source files referenced in these examples have been updated to use the new Window APIs, and here is a brief overview of the relevant API signatures:
- AWTUtilities.isTranslucencySupported(Translucency) is now GraphicsDevice.isWindowTranslucencySupported(WindowTranslucency).
- AWTUtilities.isTranslucencyCapable(GraphicsConfiguration) is now GraphicsConfiguration.isTranslucencyCapable().
- AWTUtilities.setWindowShape(Window, Shape) is now Window.setShape(Shape).
- AWTUtilities.setWindowOpacity(Window, float) is now Window.setOpacity(float).
- AWTUtilities.setWindowOpaque(boolean) is superceded by Window.setBackground(Color). Passing the new Color(0, 0, 0, 0) achieves the old effect of installing per-pixel translucency.
You can see the Javadocs of the new Window methods in the corresponding Mercurial diff, or in the source archive bundled with the b57 installer.
Note that the com.sun.awt.AWTUtilities class is still there, and calling its API methods still produces the correct visuals. A quick look at the implementation reveals that the AWTUtilities methods do not (yet) go directly to the new Window methods, perhaps converging deeper in the AWT internals.
Related posts:
- Translucent and shaped windows in core Java I first spotted it about a month ago, and today’s build 12 of JDK 6.0u10...
- More tricks with translucent Swing windows The java.net site has just published my article on translucent and shaped windows, and it...
- Soft clipping and per-pixel translucency for Swing windows The entry on translucent and shaped windows in Swing has generated quite a lot of...
May 3rd, 2009 at 3:10 pm
[...] Java 7 just got public API support for shaped and translucent windows , and Kirill Grouchnikov is kind enough to provide an overview of the changes. [...]
May 4th, 2009 at 1:22 am
And when will be JDK 7 released? ;)
May 4th, 2009 at 6:45 am
David, see
http://weblogs.java.net/blog/forax/archive/2009/05/jdk7_milestones.html
May 4th, 2009 at 10:18 am
Does the performance lack (http://forums.java.net/jive/thread.jspa?messageID=321379) still exist?
May 5th, 2009 at 10:14 am
Wolfgang – why not ask the AWT developers in the same thread?
May 5th, 2009 at 11:10 pm
Sorry, just wanted to bother someone else ;-)
I’ve already checked b57 and beside other (more important) issues the mentioned issue still exists.