日期:2014-05-20  浏览次数:20767 次

JAVA 控制台创建GUI程序如何设置窗体背景?
我在JAVA 控制台里面创建GUI程序如何设置窗体的背景颜色?
我在main方法中加入代码frame.setBackground(Color.yellow);在JFrame的子类中的构造方法中添加this.setBackground(Color.red); 都出现不了效果?不知道怎么回事?
我是用MyEclipse 8.5做的!

------解决方案--------------------
被contentpane的组件挡住了。
------解决方案--------------------
JFrame不能直接设置背景色,你可以这样设置this.getContentPane.setBackground(Color.black);