package youg; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Toolkit; import java.net.URL; import javax.swing.JPanel; public class contentPane extends JPanel { /** * */ private static final long serialVersionUID = 1L; private URL imgPath; @Override public void paintComponent(Graphics gs) { Graphics2D g = (Graphics2D) gs; super.paintComponent(g); //»±³¾°Í¼Æ¬ Image image=Toolkit.getDefaultToolkit().getImage(getImgPath()); g.drawImage(image, 0, 0, this.getSize().width,this.getSize().height, this); } public URL getImgPath() { return imgPath; } public void setImgPath(URL imgPath) { this.imgPath = imgPath; } }