Import java.aw. *; import java.swing. *; import java.awt.event. *; public class huatu import.event. *; public class huatu import.Event. *; public class huatu import.Event. *; public class huatu import.Event. Public static void main (string arg []) {jframe f = new jframe ("paint"); Container P = f.getContentPane (); p.setLayout (new flowLayout ()); jbutton jbutton1 = new jbutton ("red" ); Jbutton jbutton2 = new jbutton ("black"); jbutton jbutton3 = new jbutton ("exit"); // Graphics G.SetColor (New Color (255, 0)); // Buttonevent arg = New Buttonevent Arg); jbutton1.addActionListener (new hurddactionlistener (new hurdata); new hurdum ()); p.AddmouseMotionListener (new hurd (jbutton1); P.Add (jButton2); P.Add (jButton3); F.Setsize (200, 200); f.show ();} public void actionPerformed (E.GetActionCommand (). Equals ("red") ) {FLAG = 1;} else if (E.GetActionCommand (). Equals ("black")) {FLAG = 2;} else if (E.Geta Ctioncommand (). Equals ("Exit")) System.exit (0);} public void mousedragged (MouseEvent E) {Container C = (Container) E.Getsource (); graphics g = c.getgraphics (); if ( OX> = 0) {IF (flag == 1) {G.SetColor (New Color (168, 0, 255)); g.drawline (OX, Oy, E.GETX (), ELETY ());} else {G.SetColor (New Color (0,0,0)); g.drawline (OX, OY, E.GETX (), E.GETY ());}} ox = E.GETX (); = e PUBLIC VOID MOUSEMOVED (MouseEvent E) {ox = -1;}}}