Import java. Applet .*;
Import java. AWT .*;
Import java. AWT. event .*;
Import java. AWT. Geom. *; // contains the graphics2d class. This class (paint brush) can be set to rotate.
Public class ellipse extends applet implements runnable
{
Int appletwidth, appletheight;
Ellipse2d e2d; // elliptical paint brush
Affinetransform Tans; // used for rotation
Thread thread;
Image offscreen; // place the sub-screen on the main screen to eliminate the flash disadvantage.
Graphics2d drawoffscreen;
Public void inint ()
{
This. setbackground (color. Black );
Appletwidth = getsize (). width;
Appletheight = getsize (). height;
E2d = new ellipse2d. Double (30, 30, 80, 30 );
Tans = new affinetransform ();
Offscreen = createimage (appletwidth, appletheight );
Drawoffscreen = (graphics2d) offscreen. getgraphics ();
}
Public void start ()
{
Thread = new thread (this );
Thread. Start ();
}
Public void stop ()
{
Thread = NULL;
}
Public void Update (Graphics g)
{
Paint (g );
}
Public void paint (Graphics g)
{
G. drawimage (OFFSCREEN, 0, 0, this );
}
Public void run ()
{
While (true)
{
Drawoffscreen. clearrect (0, 0, appletwidth, appletheight );
Drawoffscreen. setcolor (color. White );
Tans. Rotate (15.0 * Math. PI/180, 70, 45 );
Drawoffscreen. settransform (TANS );
Drawoffscreen. Draw (e2d );
Repaint ();
Try {
Thread. Sleep (33 );
}
Catch (interruptedexception e ){}
}
}
}