A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 小鱼儿211 中级黑马   /  2015-10-17 22:42  /  2568 人查看  /  4 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

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);
        }
}

4 个回复

倒序浏览
赞一个,顶一下
回复 使用道具 举报
QiChen 来自手机 中级黑马 2015-10-20 00:05:14
藤椅
没有运行的结果么?拿去试试看,
回复 使用道具 举报
想要看运行结果。
回复 使用道具 举报

你可以试试,满天星,很不错
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马