利用 javax.swing.JPanel ,重载paintComponent 方法,
public void paintComponent(Graphics gs) {
Graphics2D g = (Graphics2D) gs; super.paintComponent(g);
//画背景图片 Image image = Toolkit.getDefaultToolkit().getImage(getClass().getResource(imgPath));
g.drawImage(image, 0, 0,width,height, this); }
|