[英]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? 任何想法为什么会这样?
好吧,只需使用this.setUndecorated(true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.