update( )

Lavatron overrides update f ) to do nothing, because we don’t want AWT’s implementation to cause flicker,

paint( )

The paint() method is quite simple. The first step calls copyArea( ) to all of the columns to the left by one column’s width, Then a for loop is used to fill the rightmost column with rectangles in the Color of the appropriate pixel, using colort ). The bulb image strip is then painted over the new column. Then the current scrolled position scrollX, is updated to be one more to the right, modulo the width pixscan.

 start( ), stope (), and rune( )

When the applet starts, it creates and starts a new Thread called t. This thread will call . run(), which will keep calling paint() as fast-as possible, while maintaining the courtesy of calling yield( ) so that other threads can run. When the applct stop( ) method is called, stopFIag is set to true. This variable is checked by the infinite loop in the run] ) method. Program control breaks from the loop when stop Flag is true. An interesting enhancement would be to introduce a threshold frame rate, say 30 fps (frames per second), and change the call to the yield() into an appropriate. call to sleept ) if the rendering is too fast. Applets will soon seem too fast if we don’t all start to think about adaptive behaviors to achieve constant frame rates.

reCAPTCHA is required.

Share This