我有以下类(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();
}
});
}
}
但是,当我尝试运行该程序时,出现以下错误:
Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decorated
at java.awt.Frame.setBackground(Unknown Source)
有什么想法为什么会发生这种情况吗?
最佳答案
好吧,只需使用this.setUndecorated(true)
关于java - 创建一个完全透明的JFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39679426/