package view.component;

import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;

/**
 * ¿ÉÒÔÏÔÊ¾±³¾°Í¼Æ¬µÄPanel ÐÂ½¨¶ÔÏóºó£¬µ÷ÓÃsetImage·½·¨ÉèÖÃ±³¾°Í¼Æ¬¼´¿É
 * 
 */

public class BackGroundPanel extends AlphaPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -9019459739887040408L;
	private Image image;

	public BackGroundPanel() {
		super();
		setOpaque(false);
		setLayout(null);
	}

	public void setImage(Image image) {
		this.image = image;
	}

	protected void paintComponent(Graphics g) {
		if (image != null) {
			int width = getWidth();// »ñÈ¡×é¼þ´óÐ¡
			int height = getHeight();
			g.drawImage(image, 0, 0, width, height, this);// »æÖÆÍ¼Æ¬Óë×é¼þ´óÐ¡ÏàÍ¬
		}
		super.paintComponent(g);// Ö´ÐÐ³¬Àà·½·¨
	}

}
