首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

使JFrame透明但是里头的组件不透明

2013-07-08 
使JFrame透明但是里面的组件不透明jdk7 中可以 通过设置 一个 带有 alpha的背景色来设置窗口 透明/半透明。

使JFrame透明但是里面的组件不透明
jdk7 中可以 通过设置 一个 带有 alpha的背景色来设置窗口 透明/半透明。
frame.setUndecorated(true);
frame.setBackground(new Color(0,0,0,0));

如果你使用的是最丑的 Metal 观感,可以 使用 JFrame.setDefaultLookAndFeelDecorated(true);

--------------------------------------
java setUndecorated(true)出错 

this.setUndecorated(true);

出现错误Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is displayable.

解决办法

this.dispose();

this.setUndecorated(true);

转自http://bbs.csdn.net/topics/370132863
http://huoluotongjie.blog.163.com/blog/static/188993022201161831258253/

热点排行