package org. jetic. web. chat; import java. awt. *; import java. applet. *; import java. awt. event. *; import javax. swing. *; public class ChatApplet extends Applet implements MouseListener, Runnable {int x, y; int top, point;/*** initializes the variables and colors of the Applet. */Public void init () {x = 0; y = 0; // set the background Color to black setBackground (Color. black); addMouseListener (this);} public void paint (Graphics g) {}/ *** enables the program to run as an application. */Public static void main (String args []) {ChatApplet applet = new ChatApplet (); JFrame frame = new JFrame ("TextAreaNew"); frame. addWindowListener (new WindowAdapter () {public void windowClosing (invalid wevent e) {System. exit (0) ;}}); frame. getContentPane (). add (applet, BorderLayout. CENTER); frame. setSize (800,400); applet. init (); applet. start (); frame. setVisible (true);}/*** program main thread, draw a fireworks. */Public void run () {// variable initialize Graphics g1; g1 = getGraphics (); int y_move, y_click, x_click; int v; x_click = x; y_click = y; y_move = 400; v = 3; int r, g, B; while (y_move> y_click) {g1.setColor (Color. black); g1.fillOval (x_click, y_move, 5, 5); y_move-= 5; r = (int) Math. round (Math. random () * 4321) % 200) + 55; g = (int) Math. round (Math. random () * 4321) % 200) + 55; B = (int) Math. round (Math. random () * 4321) % 200) + 55; g1.setColor (new Color (r, g, B); g1.fillOval (x_click, y_move, 5, 5); for (int j = 0; j <= 10; j ++) {if (r> 55) r-= 20; if (g> 55) g-= 20; if (B> 55) B-= 20; g1.setColor (new Color (r, g, B); g1.fillOval (x_click, y_move + j * 5, 5);} g1.setColor (Color. black); g1.fillOval (x_click, y_move + 5*10, 5, 5); try {Thread. currentThread (). sleep (v ++);} catch (InterruptedException e) {}} for (int j = 12; j> = 0; j --) {g1.setColor (Color. black); g1.fillOval (x_click, y_move + (j * 5), 5); try {Thread. currentThread (). sleep (v ++)/3);} catch (InterruptedException e) {}} y_move = 400; g1.setColor (Color. black); while (y_move> y_click) {g1.fillOval (x_click-2, y_move, 9, 5); y_move-= 5;} v = 15; for (int I = 0; I <= 25; I ++) {r = (int) Math. round (Math. random () * 4321) % 200) + 55; g = (int) Math. round (Math. random () * 4321) % 200) + 55; B = (int) Math. Round (Math. random () * 4321) % 200) + 55; g1.setColor (new Color (r, g, B); g1.drawOval (x_click-3 * I, y_click-3 * I, 6 * I, 6 * I); if (I <23) {g1.drawOval (x_click-3 * (I + 1), y_click-3 * (I + 1), 6 * (I + 1 ), 6 * (I + 1); g1.drawOval (x_click-3 * (I + 2), y_click-3 * (I + 2), 6 * (I + 2 ), 6 * (I + 2);} try {Thread. currentThread (). sleep (v ++);} catch (InterruptedException e) {} g1.setColor (Color. black); g1.drawOval (x_click-3 * I, y_click-3 * I, 6 * I, 6 * I );}} /*** Listens to mouse events. * Click the mouse to listen to the event. * When you press the mouse, a new thread is generated. */Public void mousePressed (MouseEvent e) {x = e. getX (); y = e. getY (); Thread one; one = new Thread (this); one. start (); one = null;}/*** implements the MouseListener method. Is an empty method. */Public void mouseReleased (MouseEvent e) {}/ *** implements the method in MouseListener. Is an empty method. */Public void mouseEntered (MouseEvent e) {}/ *** implements the MouseListener method. Is an empty method. */Public void mouseExited (MouseEvent e) {}/ *** implements the method in MouseListener. Is an empty method. */Public void mouseClicked (MouseEvent e ){}}