アットウィキロゴ

pro game12

import java.io.*;
import java.awt.*;
import java.awt.Graphics;
import java.awt.event.*;
import java.net.URL;
import javax.sound.sampled.*;

class game12 extends Frame implements Runnable{

Image img1,img2;
int t;

public static void main(String [] args) {
        Frame f=new game12();
        f.setTitle("game12");
        f.setSize(700,700);
        f.setBackground(Color.yellow);
        f.setVisible(true);
    }

game12(){

img1 = Toolkit.getDefaultToolkit().getImage("100.jpg");
img2 = Toolkit.getDefaultToolkit().getImage("777.jpg");



Thread th=new Thread(this);
th.start();
addWindowListener(new stopwin());
}


class stopwin extends WindowAdapter{
    public void windowClosing(WindowEvent we){System.exit(0);}
}  


public void run(){
t=1;
while(t<100){

repaint();
try{
Thread.sleep(100);
}catch(InterruptedException e){}
t=t+1;

if (t==10){

try {URL url = this.getClass().getClassLoader().getResource("a1.wav");
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.start();}
catch (UnsupportedAudioFileException e) {e.printStackTrace();}
catch (IOException e) {e.printStackTrace();}
catch (LineUnavailableException e) {e.printStackTrace();}


}

}  
}

public void paint(Graphics g){
if(t<50)g.drawImage(img1,100,100,500,500,this);
if(t>50)g.drawImage(img2,100,100,500,500,this);

}

}
最終更新:2011年01月30日 22:05