亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

java實(shí)現(xiàn)的滿天星效果實(shí)例

 更新時(shí)間:2014年11月11日 16:02:22   投稿:shichen2014  
這篇文章主要介紹了java實(shí)現(xiàn)滿天星效果的方法,涉及Java繪圖的應(yīng)用,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了java實(shí)現(xiàn)滿天星效果的方法。分享給大家供大家參考。

具體實(shí)現(xiàn)代碼如下:

復(fù)制代碼 代碼如下:

import java.awt.*;

public class Main {
        public static void main(String[] args) {
                Frame frame = new Frame("滿天星");
                MyPanel panel = new MyPanel();
                frame.add(panel);
                frame.setBackground(Color.BLACK);
                frame.setSize(1024, 768);
                frame.setVisible(true);
        }
}

class MyPanel extends Panel {
        private static final long serialVersionUID = 1L;

        public void paint(Graphics g) {
                g.setColor(Color.WHITE);
                for (int i = 0; i < 300; i++) {
                        g.drawString("*", (int) (Math.random() * 1024),
                                        (int) (Math.random() * 768));
                }
                g.fillOval(800, 100, 100, 100);
                g.setColor(Color.BLACK);
                g.fillOval(780, 80, 100, 100);

        }

}

運(yùn)行效果如下圖所示:

希望本文所述對(duì)大家的Java程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論