title: JFrame with blurred transparent background
body: <p>I would like to do a blur on the background of the JFrame which is transparent to show what is happening underneath it, but I have no idea how can I blur the background and avoid flickering. What I want to achieve is to have a transparent background which is slighlty blurred, but still shows "live view" of the windows underneath it, not to have a blurred static picture which doesn't change.
  Keep in mind that the window may take the size of full screen.</p>
  
  <p>I hope I described it correctly, as I am still a beginner in Java Graphics.</p>
  
  <p>The transparent frame in code:</p>
  
  <pre><code>import java.awt.Color;
  import java.awt.Graphics;
  import javax.swing.JFrame;
  
  public class BlurredBackgroundWindow {
  
      public static void main(String[] args) {
          new BlurredBackgroundWindow().drawGUI();
      }
  
      public void drawGUI() {
          myJFrame frm = new myJFrame();
          frm.setTitle("BlurredBackgroundWindow");
          frm.setSize(480, 360);
          frm.setUndecorated(true);
          frm.setBackground(new Color(0,0,0,1));
          frm.setLocationRelativeTo(null);
          frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          frm.setVisible(true);
      }
  
      class myJFrame extends JFrame {
  
          public void paint(Graphics g) {
              super.paint(g);
  
              // Doing the rest of painting here
          }
  
      }
  
  }
  </code></pre>
  
  <p>Note - The frame is completely transparent and to see some effect change the color to eg.</p>
  
  <pre><code>frm.setBackground(new Color(0,100,0,100));
  </code></pre>
  
  <p>Thanks for any help</p>
  
  <p>EDIT 1:
  Here is the effect in action WITH the flickering which I want to avoid, but I don't really know how... This one works for a fullscreen window only.</p>
  
  <pre><code>import java.awt.AWTException;
  import java.awt.Color;
  import java.awt.Dimension;
  import java.awt.Graphics;
  import java.awt.Rectangle;
  import java.awt.Robot;
  import java.awt.Toolkit;
  import java.awt.image.BufferedImage;
  import java.awt.image.BufferedImageOp;
  import java.awt.image.ConvolveOp;
  import java.awt.image.Kernel;
  import java.util.Timer;
  import java.util.TimerTask;
  
  import javax.swing.JFrame;
  
  public class BlurredBackgroundWindow {
  
      public static int FPS = 2;
      private BufferedImage temp = null;
      private BufferedImage out = null;
      private BufferedImage image = null;
  
      myJFrame frm = new myJFrame();
  
      public static void main(String[] args) {
          new BlurredBackgroundWindow().drawGUI();
      }
  
      public void drawGUI() {
          frm.setTitle("BlurredBackgroundWindow");
          frm.setExtendedState(JFrame.MAXIMIZED_BOTH);
          frm.setUndecorated(true);
          frm.setBackground(new Color(0,0,0,1));
          frm.setLocationRelativeTo(null);
          frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          frm.setVisible(true);
  
          Timer bcg = new Timer();
          bcg.schedule(new TimerTask() {
  
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              Rectangle screenRectangle = new Rectangle(screenSize);
              Robot robot;
  
              public void run() {
  
                  System.out.println("Repaint");
                  frm.repaint();
                  try {
                      robot = new Robot();
                      image = robot.createScreenCapture(screenRectangle);
                  } catch (AWTException e) {}
                  frm.repaint();
                  // Save the blurred image for debugging
                  /*try {
                      ImageIO.write(image, "png", new File("C:\\test.png"));
                  } catch (IOException e) {
                      e.printStackTrace();
                  }*/
  
              }
  
          }, 0, (int) (1000f/FPS));
      }
  
      class myJFrame extends JFrame {
  
          public void paint(Graphics g) {
              super.paint(g);
  
              if(image != null) {
                     float[] matrix = {
                              0.111f, 0.111f, 0.111f, 
                              0.111f, 0.111f, 0.111f, 
                              0.111f, 0.111f, 0.111f, 
                          };
                          BufferedImageOp op = new ConvolveOp( new Kernel(3, 3, matrix) );
                          temp = op.filter(image, out);
                          out = temp;
                  g.drawImage(out,0,0,null);
                  temp=null;out=null;image=null;
              }
  
          }
  
      }
  
  }
  </code></pre>