run( ) Java Help

run( )

The run( ) method starts with a loop that waits for the first image to be fully loaded before proceeding. It then finishes the initialization of the applet by calling finish lnit. From there, it enters the main loop of the program. This main loop drives the transitions between billboards. Using the delay parameter passed in from the HTML to the applet, the applet calculates when the next transition is supposed to be run. While it is waiting, it prepares for the transition. It starts the preparation by determining which billboard IS to be displayed next, parsing the billboard data from HTML parameters if this has not been done yet for this billboard. Then it randomly chooses which transition to run next, being careful not to let the applet run the same transition consecutively.

Once the applet has determined what transition will be run next, it creates a new instance of this transition class by dynamically loading the class using the String name and then creating a new instance of the class. The dynamic loading of the transition classes has. a big impact on the loading time of the applet as a whole. Instead of every single class having to be downloaded before the applet starts, only three classes are sent initially: Dynamic Billboard, and Bill Transition. TIle other transition classes are only downloaded by the applet the first time: they arc needed. This reduces the initial download ofthe applet significantly. Some class files might not even need to be sent if the user leaves the page quickly.Finally, the applet calls the init( ) method on the transition object, passing the applet and image pixels for the current and next billboard as parameters. This creates all the.cell frames that are used to animate a transition. With the transition ready·to go, the applet only need wait for the proper time to start the transition.

The applet performs the transition by using simple frame animation-drawing each cell in order orito the screen, with a short delay between each frame. The applet calls the toolkit method sync( ) just to be sure that the drawing of one cell does not take place before the pr~vious cell has been shown on the screen. After the last cell is’ displayed, the applet draws the image from the next billboard onto the screen to complete the transition.

Following this, the mouscjoverjapplet flag is checked to see if the mouse cursor is currently over the applet, If so, the URL of the previous billboard is showing on the status bar and must be updated to reflect the URL of the new billboard. This is done with a call to the applet method showStatus( ). The applet has completed this transition and is now ready to begin the next one.

JavaHelpOnline.com

  • Feel free to send us an inquiry, we will reply back in hours.
 

Verification

Posted on September 18, 2014 in The Dynamic Billboard Applet

Share the Story

About the Author

Back to Top