try{
BufferedImage src = ImageIO.read(new File("c:/ship.jpg")); // 讀入文件
BufferedImage src1 = ImageIO.read(new File("c:/ship2.jpg")); // 讀入文件
BufferedImage src2 = ImageIO.read(new File("c:/ship3.jpg")); // 讀入文件
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.setRepeat(0);
e.start("c:/laoma.gif");
e.setDelay(3000); // 1 frame per sec
e.addFrame(src);
e.setDelay(1000);
e.addFrame(src1);
e.setDelay(100);
e.addFrame(src2);
e.finish();
}catch(IOException e){
e.printStackTrace();
}