[英]Create a completely transparent JFrame
我有以下課程
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.