資源簡介
一個雪景動畫小程序,有雪人,有雪,雪在飛行,有詳細注釋。
代碼片段和文件信息
import?java.awt.*;
import?javax.swing.*;
public?class?Snow?extends?Jframe{
public?static?void?main(String?args[]){
Jframe?w?=?new?Jframe();
w.setSize(1024768);
/*w.setBackground(Color.BLACK);*/
MyPanel133?m=new?MyPanel133();
m.setBackground(new?Color(3512205));
Thread?th?=new?Thread(m);
th.start();
w.add(m);
w.show();
}
}
class?MyPanel133?extends?JPanel?implements?Runnable{
/*int?x=(int)?(Math.random()*700);
int?y=(int)?(Math.random()*700);*/
int[]?x=new?int[300];
int[]?y=new?int[300];
public?MyPanel133(){
for(int?i=0;i<300;i++){
x[i]=(int)(Math.random()*1024);
y[i]=(int)(Math.random()*768);//填充300個隨機數到數組中
}
}
public?void?paint(Graphics?g){
super.paint(g);
Font?f=new?Font(““Font.BOLD30);
g.setFont(f);//設置大小
g.setColor(new?Color(255255255));
for(int?i=0;i<300;i++){
g.drawString(“*“x[i]y[i]);
}//畫雪
g.setColor(new?Color(22922742));
g.fillOval(850709090);
g.setColor(new?Color(444352));
g.fillPolygon(new?int[]{710710830830}?new?int[]{570590600580}?4);//手
g.setColor(new?Color(3512205));
g.fillPolygon(new?int[]{750710680}?new?int[]{580570600}?3);
g.setColor(new?Color(444352));
g.fillPolygon(new?int[]{970970830830}?new?int[]{570590600580}?4);//手
g.setColor(new?Color(3512205));
g.fillPolygon(new?int[]{9309701000}?new?
- 上一篇:java實現的系統進程調度實驗
- 下一篇:企業論壇系統 jsp + servlet
評論
共有 條評論