//Http://community.9cbs.net/expert/topic/3672/3672834.xml?temp=5.533999E-02import java.awt. *; import java.awt.event. *; import javax.swing. *;
public class yanhua extends JComponent implements Runnable {Image img; Graphics ig; public static void main (String arg []) {JFrame f = new JFrame ( "Paint"); f.setBackground (Color.black); Container c = f. GetContentPane (); Flash Flash = New Flash (); C.Add (Flash); F.Pack (); f.show ();
New thread (flash) .start (); public dimension getPreferRedsize () {return (New Dimension (300, 300));} public void run () {INT i, J, K; int T = 15, per = 20, N = T * per; int x [], y [], delay []; x = new int [t]; y = new int [t]; delay = new int [t]; color c [] = new color [ T]; try {thread.sleep (1000);} catch (exception e) {} fire f [] = new fire [n]; for (i = 0; i Public void Paint (GRAPHICS G) {IF (IMG == NULL) {IMG = CreateImage (300); IG = img.getgraphics ();} g.drawImage (IMG, 0, 0, 300, 300, NULL);}} Class Fire { Static double ga = 9.8, delta = 0.05; private double dx, dy; private double [] x = new double [3], y = new double [3]; graphics g; color C; private int CNT; Public Fire (Double X, Double Y, Double XDirection, Double Ydirection, Graphics G, Color C) {dx = xdirection; dy = ydirection; this.x [0] = x; THIS.Y [0] = Y; g = g; this.c = C; cnt = 0;} Public void move () {CNT ; IF (CNT% 20 == 0) this.c = this.c.darker (); color c = this.c; int i; for (i = 2 ;; I -) {G.setcolor (color.ble); g.Filloval ((int) x [i], (int) y [i], 3, 3); if (i == 0) Break; x [i] = x [i-1]; y [i] = y [i-1];} x [0] = dx * delta; y [0] = DY * DELTA; DY = Ga * Delta; for (i = 0 i <3; i ) {g.setcolor (c); g.Filloval ((int) x [i], (int) y [i], 3, 3); c = c.darker ();}} }