You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.0 KiB
29 lines
1.0 KiB
package com.utils;
|
|
|
|
import java.awt.Container;
|
|
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JPanel;
|
|
// 背景图片设置
|
|
public class BackgroundImagelyx {
|
|
public BackgroundImagelyx(JFrame frame,Container container,String ImageName) {
|
|
// 限定加载图片路径
|
|
ImageIcon icon= new ImageIcon("res/" + ImageName);
|
|
|
|
final JLabel labelBackground = new JLabel();
|
|
ImageIcon iconBookManageSystemBackground = icon;
|
|
labelBackground.setIcon(iconBookManageSystemBackground);
|
|
// 设置label的大小
|
|
labelBackground.setBounds(0,0,iconBookManageSystemBackground.getIconWidth()
|
|
,iconBookManageSystemBackground.getIconHeight());
|
|
//将背景图片标签放入桌面面板的最底层
|
|
frame.getLayeredPane().add(labelBackground,new Integer(Integer.MIN_VALUE));
|
|
// 将容器转换为面板设置为透明
|
|
JPanel panel = (JPanel)container;
|
|
panel.setOpaque(false);
|
|
|
|
}
|
|
}
|