Display a Java jump page

Source: Internet
Author: User

Author: numenzq

Http://www.j2medev.com/Article/ShowArticle.asp? ArticleID = 1134

Advanced JAVA games/applications can be started for a long time. If you display a beautiful jump page on a program, it will usually increase the user's preference. However, this effect may exceed your imagination.

If you try to display a jump page in the main thread, you may encounter problems. You will notice that when your program starts and runs in sequence, the jump page will flash. Maybe it won't appear at all! This is possible, as long as your code is similar to the following:

Public void Startapp (){
Mydisplay. setcurrent (mysplashscreen );
Doallslowinitializations ();
Mydisplay. setcurrent (mygamescreen );
}

This problem occurs because the application manager does not allow any screen or canvas to be seen during the execution of the Startapp () method. For more information, see the MIDP javadoc javax. microedition. lcdui package.

The trick is to use different threads to process the display jump page and game initialization, as in the following code example. This will enable the Startapp () method to be executed quickly and display the page as long as possible. The two threads can use shared variables for synchronization. When Initialization is complete, the jump page should disappear.

Public void Startapp (){
Thread splashscreentest = new thread (New splashscreentest. splashscreen ());
Splashscreentest. Start ();

Thread mygamethread = new thread (this );
Mygamethread. Start ();
}

The example program below uses this technology to display a jump page.

In addition, most conventional technologies use late loading to reduce startup time, which means they are initialized only when objects and resources are used. This method can effectively reduce the memory requirements of your program, but the program also has the risk of errors, which should be carefully considered.

 

Download program source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.