package tes; //俺用。消さないとエラー吐くよ! import java.awt.Frame; import java.awt.Graphics; import java.awt.Image; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.ImageProducer; import java.net.URL; @SuppressWarnings("serial") public class animation extends Frame implements Runnable { Image s_run[] = new Image[10]; //画像用 URL s_url[] = new URL[10]; //画像のアドレス用 boolean a = true; //動かす用 int i=0; //動かす画像番号 public animation(){ this.setSize(70,170); // 画像読み込み for(int j=0;j<10;j++){ if(j<9) s_url[j] = this.getClass().getResource("/s_run0" + (j+1) + ".png"); else s_url[j] = this.getClass().getResource("/s_run" + (j+1) + ".png"); } try { for(int j=0;j<10;j++) s_run[j] = this.createImage((ImageProducer)s_url[j].getContent()); } catch(Exception ex){} // ここまで画像読み込み //×ボタン用 this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent ev){ System.exit(0); } }); //ここまで×ボタン用 new Thread(this).start();//スレッドスタート this.setVisible(true); } public static void main(String[] args) { new animation(); } /*public void update(Graphics g) { paint(g); }*/ public void paint(Graphics g){ g.drawImage(s_run[i],20,50,this); } public void run() { while(a == true){ i++; if(i>9) i=0; try{ Thread.sleep(100); //スリープ1秒 }catch(InterruptedException e){} repaint(); } } }