x, y);=new Dimension (x, y);=false; true;
} boolean mouseUp (Event evt, x, int y)
{(bDrawing)
{= new Dimension (x, y) ;. addElement (Rectangle (dmDown.width, .height, x, y)); ();=false;
} true;
} boolean mouseDrag (Event evt, x, int y)
{g=getGraphics ();=true; .setColor (Color.yellow) ;. drawLine (dmDown.width, dmDown.height, .width, dmPrev.height) ;. setColor (Color. black) ;. drawLine (dmDown.width, .height, x, y);=new Dimension (x, y); true;
} boolean mouseMove (Event evt, x, int y)
{= false; true;
}
}
Додаток 3
java.applet. *; java.awt. *; class hello extends Applet
{m_DrawRectThread=null; m_DrawEllipseThread=null;
//NotifyTask m_NotifyTaskThread=nullString getAppletInfo ()
{ Name: Rectangles raquo ;;
} void paint (Graphics g)
{dimAppWndDimension=getSize () ;. setColor (Color.yellow) ;. fillRect (0, 0, .width - 1, .height - 1) ;. setColor (Color.black) ;. drawRect (0, 0, .width - 1, .height - 1);
} void start ()
{(m_DrawRectThread == null)
{_ DrawRectThread=DrawRectangles (this); _ DrawRectThread.start ();
} (m_DrawEllipseThread == null)
{_ DrawEllipseThread=DrawEllipse (this); _ DrawEllipseThread.start ();
}
//if (m_NotifyTaskThread == null)
{
//m_NotifyTaskThread=NotifyTask (m_DrawEllipseThread);
//m_NotifyTaskThread.start ();
}
}
void stop ()
{(m_DrawRectThread!=null)
{_ DrawRectThread.stop (); _ DrawRectThread=null;
} (m_DrawEllipseThread == null)
{_ DrawEllipseThread.stop (); _ DrawEllipseThread=null;
} (m_NotifyTaskThread!=null)
{_ NotifyTaskThread.stop (); _ NotifyTaskThread=null;
}
}
} DrawRectangles extends Thread
{g; dimAppWndDimension; DrawRectangles (Applet Appl)
{= Appl.getGraphics ();=Appl.getSize ();
} void run ()
{(true)
{x, y, width, height; rColor, gColor, bColor;=(int) (dimAppWndDimension.width
* Math.random ());=(int) (dimAppWndDimension.height
* Math.random ());=(int) (dimAppWndDimension.width
* Math.random ())/2;=(int) (dimAppWndDimension.height
* Math.random ())/2;=(int) (255 * Math.random ());=(int) (255 * Math.random ());=(int) (255 * Math.random ()) ;. setColor (new Color (rColor ,, bColor)) ;. fillRect (x, y, width, height);
{. sleep (50);
} (InterruptedException e)
{();
}
}
}
} DrawEllipse extends Thread
{g; dimAppWndDimension; DrawEllipse (Applet Appl)
{= Appl.getGraphics ();=Appl.getSize ();
} synchronized void run ()
{(true)
{x, y, width, height; rColor, gColor, bColor;=(int) (dimAppWndDimension.width
* Math.random ());=(int) (dimAppWndDimension.height
* Math.random ());=(int) (dimAppWndDimension.width
* Math.random ())/2;=(int) (dimAppWndDimension.height
* Math.random ())/2;=(int) (255 * Math.random ());=(int) (255 * Math.random ());=(int) (255 * Math.random ()) ;. setColor (new Color (rColor ,, bColor)) ;. fillOval (x, y, width, height);
{. wait ();
} (InterruptedException e)
{
}
}
}
} NotifyTask extends Thread
{STask; NotifyTask (Thread SynchroTask)
{= SynchroTask;
} void run () {(true)}
{try} .sleep (30);} (InterruptedException e)
{
} (STask)
{. notify ();
}