I'm playing with JDK7's translucent window support and find that it doesn't work well with Windows look and feel.
Here's my code:
JFrame.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("Translucent Window");
frame.setOpacity(0.5F);
frame.setSize(640, 360);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
}
This code correctly displays a translucent window. However, if I set the Windows look and feel:
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
an exception is thrown:
Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decorated
If I disable the frame decoration with frame.setUndecorated(true)
, it works again but that is not what I want because the title bar is missing. Is there any way to resolve this issue?