当前位置: 移动技术网 > IT编程>开发语言>Java > 设置JFrame背景图片

设置JFrame背景图片

2018年11月11日  | 移动技术网IT编程  | 我要评论

贵州省人事考试信息,郑伟平,御龙在天跳舞

这里我就放上改写的代码吧,不做多的解释,推荐一个好的博文

 1 public void ini_background() {
 2     // 背景图片
 3     imageicon background = new imageicon(
 4                 this.getclass().getresource("/img/登录背景.png"));
 5     // 把背景图片显示在一个标签里面
 6     jlabel label = new jlabel(background);
 7     // 设置标签大小
 8     label.setbounds(0, 0, 440, 335);
 9     // 把内容窗格转化为jpanel,否则不能用方法setopaque()来使内容窗格透明
10     jpanel imagepanel = (jpanel) this.getcontentpane();
11     imagepanel.setopaque(false);
12     this.getlayeredpane().setlayout(null);
13     // 把背景图片添加到分层窗格的最底层作为背景
14     this.getlayeredpane().add(label, new integer(integer.min_value));
15 }

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网