博客
关于我
Java_GUI_图片当做背景
阅读量:590 次
发布时间:2019-03-11

本文共 415 字,大约阅读时间需要 1 分钟。

//背景图片的路径。(相对路径或者绝对路径。本例图片放于"java项目名"的文件下)		String path = "background.jpg";		// 背景图片		ImageIcon background = new ImageIcon(path);

参考了上面的代码运行出来背景并没有改变,需要修改为下面的形式背景才能修改成功

ImageIcon background = new ImageIcon(Demo3.class.getResource("/background.jpg"));

!!!!注意:后面加控件的话也要设置透明,

JPanel jpanel=new JPanel();		//设置面板布局方式。把默认布局清除、自己布局方式		jpanel.setLayout(null);		//透明		jpanel.setOpaque(false);		//把面板放在窗口		frame.add(jpanel);

转载地址:http://tiitz.baihongyu.com/

你可能感兴趣的文章
MySQL: Host '127.0.0.1' is not allowed to connect to this MySQL server
查看>>
Mysql: 对换(替换)两条记录的同一个字段值
查看>>
mysql:Can‘t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock‘解决方法
查看>>
MYSQL:基础——3N范式的表结构设计
查看>>
MYSQL:基础——触发器
查看>>
Mysql:连接报错“closing inbound before receiving peer‘s close_notify”
查看>>
mysqlbinlog报错unknown variable ‘default-character-set=utf8mb4‘
查看>>
mysqldump 参数--lock-tables浅析
查看>>
mysqldump 导出中文乱码
查看>>
mysqldump 导出数据库中每张表的前n条
查看>>
mysqldump: Got error: 1044: Access denied for user ‘xx’@’xx’ to database ‘xx’ when using LOCK TABLES
查看>>
Mysqldump参数大全(参数来源于mysql5.5.19源码)
查看>>
mysqldump备份时忽略某些表
查看>>
mysqldump实现数据备份及灾难恢复
查看>>
mysqldump数据库备份无法进行操作只能查询 --single-transaction
查看>>
mysqldump的一些用法
查看>>
mysqli
查看>>
MySQLIntegrityConstraintViolationException异常处理
查看>>
mysqlreport分析工具详解
查看>>
MySQLSyntaxErrorException: Unknown error 1146和SQLSyntaxErrorException: Unknown error 1146
查看>>