我还是赞成一楼的方法,重写paint方法是最直接的...给你个例子
import java.awt.*;
import javax.swing.*;
public class TestFrame extends JFrame {
private Image image = null ;
private ImageIcon icon = new ImageIcon("E:\\壁纸\\动漫超赞CG壁纸1920x1200(38P)\\001.jpg");
public TestFrame(){
super("测试窗口");
Toolkit toolkit = this.getToolkit();
Dimension dimension= toolkit.getDefaultToolkit.getScreenSize();
this.setSize(dimension.width,dimension.height);
this.setVisible(true);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
public static void main(){
new TestFrame();
}
//绘制背景这个方法jvm会自动调用
public void paint(Graphics g){
super.paint();
image = icon.getImage();
g.drawImage(image,0,0,null);
}
}
在paint 方法里面画
学习....