import java.awt.*;
import javax.swing.*;
class Snow extends JFrame implements Runnable{
int x[] = new int[100] ;
int y[] = new int[100] ;
Snow(){
setSize(640,480);
setLocation(200,100);
setTitle("下雪了");
for(int i = 0 ; i < 100 ; i ++){
x[i] = (int)(Math.random()*640) ;
y[i] = (int)(Math.random()*480) ;
}
}
public void run(){
while(true){
for(int i = 0 ; i < 100 ; i ++){
y[i] ++ ;
if(y[i] >= 480){
y[i] = 0 ;
x[i] = (int)(Math.random()*640) ;
}
}
try{Thread.sleep(20) ;}catch(Exception e){}
this.repaint() ;
}
}
public void paint(Graphics g){
Image i1=Toolkit.getDefaultToolkit().getImage("15.jpg");
g.drawImage(i1,0,0,this);
g.setColor(Color.WHITE) ;
Font f = new Font("" , Font.BOLD , 25) ;
g.setFont(f) ;
for(int i = 0 ; i <100 ; i ++){
g.drawString("*" , x[i] , y[i]) ;
}
}
public static void main(String args[]){
Snow s=new Snow();
s.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
s.show();
Thread t=new Thread(s);
t.start();
}
}