tropo://techno/java/starry, starry night/secrets
Starry, Starry Night Secrets
Up to java page
Back to starry, starry night intro The Big Eye means Secrets On to the playground

The Starry, Starry Night Applet is done with two classes, though in theory in could be crammed into one.

The base class TRBufferedApplet (src/javadoc) is a type of Applet that takes care of drawing into an offscreen image so as to avoid flickering.

The derived class Starry (src/javadoc ) does all the real work of parsing parameters, starting up an animation thread, tracking the mouse, and drawing the stars. The javadoc describes the parameters at the top. The key drawing method is drawStar() and it draws stars of a given size via a hardcoded switch statement.

One other hi tech thing done here is that we make sure that paint() is not called too often as otherwise that hoses the animation. TBD the frame rate applet will demonstrate this. See the private methods waitForPaint() and justPainted() and track the calls to them to see what I mean.

Make sure you see the article on animation and also tip 8 and tip 9 in Javaworld for issues with Applets resizing under Netscape.

[ Tropo ]