
本文共 3444 字,大约阅读时间需要 11 分钟。
������������������������������������������
Java������������������������������������������������������
������������������Java���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Swing������������������������������������������������������������������������������������������������������������������������������������
������������������
���������������������������������������Swing������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������������
������������������������������������������
package uu;import java.awt.Color;import java.awt.Graphics;import java.awt.Font;import java.awt.Image;import javax.swing.JFrame;import javax.swing.JPanel;import java.util.Random;public class u { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(800, 600); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(3); frame.setBackground(Color.BLACK); MyPanel p = new MyPanel(); frame.add(p); frame.setVisible(true); Thread t = new Thread(p); t.start(); }}class MyPanel extends JPanel implements Runnable { private static final long serialVersionUID = 1L; Font font = new Font("font", Font.BOLD, 50); String[] colors = {"red", "yellow", "blue"}; Random random = new Random(); int[] snowx = new int[600]; int[] snowy = new int[600]; public MyPanel() { for (int i = 0; i < 600; i++) { snowx[i] = random.nextInt(800); snowy[i] = random.nextInt(600); } } public void snowspaint(Graphics g) { g.setColor(Color.WHITE); for (int i = 0; i < 600; i++) { g.drawString("*", snowx[i], snowy[i]); for (int j = -1; j < 1; j++) { g.rotate(g, snowx[i] + j, snowy[i] + j, 30, Color.WHITE); } } } public void run() { while (true) { try { Thread.sleep(40); Graphics g = this.getGraphics(); snowspaint(g); g.dispose(); } catch (InterruptedException e) { e.printStackTrace(); } } }}
������������������������
������������������
������������������������������Swing���������������������������������������������������������������40ms���������������������������������������������������������������������
- ���������������������������colors������������������������������������������������������
- ���������������������������������������������������������������������������������
- ���������������������������������������������������������������������������
- ������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
