I am Trying to change opacity of JFrame but don't to set it Undecorated because it removes it's Tilte Bar.
I have tried this:-
JFrame subFrame = new JFrame();
subFrame.setBounds(0, 0, 500, 500);
subFrame.setVisible(true);
subFrame.setOpacity(0.80f);
But it gives error:-
Exception in thread "main" java.awt.IllegalComponentStateException: The frame is decorated
at java.awt.Frame.setOpacity(Unknown Source)
at TransparentFrame.main(TransparentFrame.java:26)
Please Help Me!!!!!!!!!
The javaDocs clearly says that the JFrame must be undecorated to use the setOpacity() method. So unfortunately it's not possible. At least not the way you do it. You can use the following ( not really clean ) workaround:
JFrame.setDefaultLookAndFeelDecorated(true); //Before you create the JFrame.
UIManager.setLookAndFeel(new MetalLookAndFeel());
Then create your JFrame instance.