Manos Kounelakis Manos Kounelakis - 2 months ago 9
Java Question

Create a completely transparent JFrame

I have the following class

public class FileCopyManager extends JFrame{

public static final Color TRANSPARENT_COLOR = new Color(0,0,0,0);
public FileCopyManager(){
this.setBackgroundColor(TRANSPARENT_COLOR);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(()->{
try {
UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch (Throwable e) {
}
finally{
new FileCopyManager();
}
});
}
}


However when I try to run this program I get the following error:

Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decorated
at java.awt.Frame.setBackground(Unknown Source)


Any Ideas why this is happening?

Answer

Well just use this.setUndecorated(true)