1.创建utils工具包,并新建ImageLoaderUtil 照片读取工具类
    public class ImageLoaderUtil {
    public static BufferedImage load(String imgName){
    BufferedImage img = null;
    try {
    URL url = ImageLoaderUtil.class.getResource(“/imgs/“+imgName);
    img = ImageIO.read(url);
    } catch (IOException e) {
    e.printStackTrace();
    }
    return img;
    }
    }
    2.创建BgRoll集成TimerTask类
    class BgRoll extends TimerTask {
    @Override
    public void run() {
    //修改y轴的值(制造背景滚动效果)
    y +=5;
    if(y >= 0){
    y = -1100; //-1100
    }
    //重绘
    repaint();
    }
    }
    3.添加Timer定时器
    //创建一个定时器对象(执行背景改变的定时任务)
    Timer timer = new Timer();
    timer.schedule(new BgRoll(),0,50);
    4.添加图标
    BufferedImage iconImage = ImageLoaderUtil.load(“icon72x72.png”);
    super.setIconImage(iconImage);