The above is the implementation of the situation, the following code, the implementation should be dynamic, interested people can run their own try:
Import Javax.swing.JFrame;
Import Javax.swing.JPanel;
Import Java.awt.Graphics;
Import Java.awt.Color;
Import Java.awt.Font;
public class Mysnow extends JFrame {
Public Mysnow () {
Snow s=new Snow ();
Thread t=new thread (s);
T.start ();
This.add (s);
This.setresizable (FALSE);
This.setsize (1366,768);
This.setdefaultcloseoperation (Jframe.exit_on_close);
}
public static void Main (string[] args) {
Mysnow ms=new Mysnow ();
Ms.setvisible (TRUE);
}
}
Class Snow extends JPanel implements runnable{
Private int[] x;
Private int[] y;
Public Snow () {
X=new int[300];
Y=new int[300];
This.setbackground (Color.Black);
}
public void Paint (Graphics g) {
Super.paint (g);
G.setcolor (Color.White);
G.setfont (New Font ("Italic", font.bold,30));
for (int i=0;i<300;i++) {
x[i]= (int) (Math.random () *1366);
y[i]= (int) (Math.random () *768);
}
for (int i=0;i<300;i++) {
g.DrawString ("*", x[i], y[i]);
}
}
public void Run () {
while (true) {
for (int i=0;i<300;i++) {
y[i]++;
if (y[i]>768) {
y[i]=0;
}
}
try{
Thread.Sleep (800);
}catch (Exception e) {
}
This.repaint ();
}
}
}
Using Java to implement snow conditions