title: Inner-Transparent Selection Window in Java using GlassPane
body: <p>I am trying to achieve the following</p>
  
  <p><a href="http://www.qksnap.com/i/3hunq/4ld0v/screenshot.png" rel="nofollow">http://www.qksnap.com/i/3hunq/4ld0v/screenshot.png</a></p>
  
  <p>I am currently able to draw rectangles successfully on a semi-transparent glasspane background using the following code:</p>
  
  <pre><code>    protected void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D) g;
            g.setColor(Color.black); // black background
            g.fillRect(0, 0, frame.getWidth(), frame.getHeight());
            g2.setColor(Color.GREEN.darker());
            if (getRect() != null &amp;&amp; isDrawing()) {
              g2.draw(getRect()); // draw our rectangle (simple Rectangle class)
            }
           g2.dispose();
  }
  </code></pre>
  
  <p>Which works great, however, I would love to have the area within the rectangle be completely transparent while the outside was still darken much like the screenshot above.</p>
  
  <p>Any ideas?</p>