Soft clipping and per-pixel translucency for Swing windows

The entry on translucent and shaped windows in Swing has generated quite a lot of discussion and interest. It appears that readers were interested in per-pixel translucency and soft clipping for shaped windows, and Anthony has provided a few tips on how to achieve this. So, pending an official guide / tutorial from the AWT team (hint hint), here is my take.

Soft clipped per-pixel translucent window

What you see here is a JWindow with soft-clipped top-left and top-right corner and pixel-level translucency in the bottom half. In addition to Anthony’s instructions, i have used the following:

The source code is here. I’m pretty sure that it’s not the best (and not the most readable), but it shows the potential. You’re more than welcome to use this code as a starting point (don’t forget to credit Chris, Romain and Sebastien if you’re reusing it).


Related posts:

  1. More tricks with translucent Swing windows The java.net site has just published my article on translucent and shaped windows, and it...
  2. Translucent and shaped windows in core Java I first spotted it about a month ago, and today’s build 12 of JDK 6.0u10...
  3. Translucent and shaped windows in JDK 7 The latest weekly drop of JDK 7 (b57) has finally exposed the functionality of translucent...
  4. Using multiple skins for different Swing windows A considerable part of the new skinning layer of Substance is geared towards enabling writing...


3 Responses to “Soft clipping and per-pixel translucency for Swing windows”

  • Keith Says:

    Hi Kirill,

    I went to a Sun Tech Days thing in Sydney yesterday and the speaker showed a screenshot of the picture in your blog of a clipped-frame! So yeah, word travels fast. In fact, the speaker (who was discussing the consumer JRE and java 7) actually seemed like he didn’t know about the window-clipping until he saw your blog.

    Thanks for putting this news up.

    Best regards,
    Keith

  • ami Says:

    why now the jdk 7.0 does not content the AWTUtilities?
    and which version contents this now?
    my email:forever_ami@163.com
    thank you !

  • Kirill Grouchnikov Says:

    Ami – that would be a question better asked on the Swing & AWT forum.