views:

857

answers:

1

I'm trying to create an overlay with a Vista Aero Glass -like background in place of a normal window. Part of my answer seems to be here, but I'm wondering how to get a blur effect in Swing/AWT. This looks like a start:

public BufferedImage processImage(BufferedImage image) {
    float[] blurMatrix = { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f, 1.0f /  
            9.0f, 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9.0f };
    BufferedImageOp blurFilter = new ConvolveOp(new Kernel(3, 3, blurMatrix),
            ConvolveOp.EDGE_NO_OP, null);
    return blurFilter.filter(image, null);
}

...but I'd really like to get a close match. It seems the process should be:

  1. Blur the background image
  2. Paint over with a transparent grey (or whatever bg color you're going for)
  3. Then paint opaque window contents

If I get this right, I might throw in the Aero window border shadows.

Am I on the right track? How precisely should I do the blur to get the same look? Maybe someone has solved this problem already? (For reference, open the Vista start menu and look at the right side.)

+1  A: 

I don't have a solution to hand but you can definitely overlay a color in the blurring stage. Everything you'll ever need to know about Swing effects and Swing image effects is in the excellent Filthy Rich Clients. The answer to your question is definitely in there.

In fact, if you look in the examples section and download the chapter 8 code from that site, there is code to do the blur and tint that you require.

Thanks, jT

Johnathan