title: Set opacity of a decorated JFrame in Java 8
body: <p>I would like to know how to get a transparent <code>JFrame</code> in the <em>latest</em> version of Java. </p>
  
  <p>Currently, you can only use </p>
  
  <pre><code>&lt;JFrame&gt;.setOpacity();
  </code></pre>
  
  <p>if the frame is <strong>not decorated</strong>.</p>
  
  <p>I have no use for an undecorated frame, so I'd like to know how to go around this restriction and set the opacity of the frame to <code>0.5f</code> while still keeping the title bar, resize options etc.</p>
  
  <p>I have read the docs here: <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html" rel="noreferrer">http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html</a>. The code only worked on <strong>Java 6</strong> and no longer runs. The error, as I said, is:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decorated
      at java.awt.Frame.setOpacity(Frame.java:960)
      at TranslucentWindowDemo$1.run(TranslucentWindowDemo.java:53)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
      ...
  </code></pre>
  
  <p>I have also tried setting the background <code>(setBackground : Color)</code> using a <code>Color</code> with custom Alpha value (<code>new Color(int, int, int, Alpha)</code>) but it throws the exact same error. 
  Setting the transaprency of a <code>JPanel</code> this way won't work, as it will still lay on the <code>JFrame</code>, which is not transparent. </p>
  
  <p>I could find no other answer on Stack Overflow that correctly addressed this issue. In fact, a few suggested that this could be fixed with:</p>
  
  <pre><code>JFrame.setDefaultLookAndFeelDecorated(true);
  </code></pre>
  
  <p>But they were misinformed of perhaps referring to Java 7, as I have tested it and the result is just the same.</p>
  
  <p>I have also tried to manually set the Look And Feel:</p>
  
  <pre><code>try {
      for (final LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
          if ("Nimbus".equals(info.getName())) {
              UIManager.setLookAndFeel(info.getClassName());
              break;
          }
      }
  
  } catch [...] 
  </code></pre>
  
  <p>And combining this with the solution suggested above also did not work.</p>
  
  <p>Please refer to the code over to the example I linked above (<a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html" rel="noreferrer">Oracle doc</a>) for a MCVE, as that is the one I'm using.</p>
  
  <p>Any way around this?</p>