Visual Mobile Designer Custom Components: Using Splash Screens in Java ME Applications

Splash screens are used to enhance the look and feel of an application. Typically, you use a splash screen when the program starts, or to display a logo or branding information. It gives users the first impression of your application. The Visual Mobile Designer (VMD) in NetBeans includes the SplashScreen custom component in the VMD palette. This brief example shows you how to create a new Java ME project using NetBeans that uses the SplashScreen component. It will also explain how to use the features to design and implement your own splash screens using this feature.

If you are new to mobile application development in NetBeans, you should start with the NetBeans Java ME MIDP Quick Start Guide before continuing.

Notes:

Contents

Content on this page applies to NetBeans IDE 7.2

To complete this tutorial, you need the following software and resources:

Software or Resource Version Required
NetBeans IDE with Java ME Version 7.2
Java Development Kit (JDK) Version 6 or version 7

Installing Visual Mobile Designer

The NetBeans Visual Mobile Designer (VMD) is a graphical interface that enables you to design mobile applications using drag and drop components. The VMD allows you to define the application flow and design your GUI using the components supplied by the IDE or components you design yourself. The VMD contains many standard User Interface (UI) components that you can use to create applications such as Lists, Alerts, Forms and Images. It also includes custom components that simplify the creation of more complex features, such as Wait Screens, Splash Screens, Table Items and more.

To install the Visual Mobile Designer plugin, complete the following steps:

  1. Choose Tools > Plugins from the main menu.
  2. On the Available Plugins tab of the Plugins dialog box, select Visual Mobile Designer and click Install.
  3. At the Welcome page of the Installer dialog box, click Next.
  4. At the License Agreement page, read the license agreements associated with the plugin. If you agree to the terms of all of the license agreements, click the appropriate option and then click Install.
  5. (Optional) Select the Run in the Background option to run the installation in the background.
  6. When the installation process is complete, click Finish.

top

Creating a Mobile Application with the SplashScreen Custom Component

Now that you have seen the SplashScreen component in action, let's go back to the beginning and create this application. To create the application do the following:

  1. Create the SplashScreen project
  2. Add Packages and a Visual MIDlet to the Project
  3. Add components to MySplashScreenMidlet
  4. Change the Timeout Property of the SplashScreen Component
  5. Add Exit and Back Commands to the Form Component
  6. Add an Image Resource
  7. Bind an Image to a Component
  8. Connect the Components
  9. Run the Project

Creating the SplashScreen Project

  1. Choose File > New Project (Ctrl-Shift-N). Under Categories, select Java ME. Under Projects, select Mobile Application and click Next.
  2. Enter SplashScreenExample in the Project Name field. Change the Project Location to a directory on your system. This directory is called $PROJECTHOME.
  3. Uncheck the Create Hello MIDlet checkbox. Click Next.
  4. Leave the CLDC Oracle Java(TM) Platform Micro Edition SDK 3.0.5 as the selected Emulator Platform. Click Finish.

Adding Packages and a Visual MIDlet to the Project

  1. Choose SplashScreenExample project in the Project Window, then choose File > New File (Ctrl-N). Under Categories, select Java. Under File Types, select Java Package. Click Next.
  2. Enter splashscreenexample in the Package Name field. Click Finish.
  3. Choose the splashscreenexample package in the Project window, then choose File > New File (Ctrl-N). Under Categories, select MIDP. Under File Types, select Visual MIDlet. Click Next.
  4. Enter MySplashScreenMIDlet into MIDlet Name and MIDP Class Name fields. Click Finish.

Adding Components to MySplashScreenMidlet

  1. Switch your Visual MIDlet to the Flow Designer. Drag the following Screen components from the Palette and drop them in the Flow Designer:
    • Splash Screen
    • Form
    The Flow Designer with the added components should look as follows:

    Flow view with added components

  2. Select the splashScreen component. In the Properties of this component, change the Title to Splash Screen and enter Wait for 10 sec. or press a key to close it into the Text property.
  3. Select the form component and change its Title property to Form.
  4. Double-click the form component in the Flow Designer to switch to the Screen Designer
  5. Select the StringItem component from the Items section of the Palette, then drag and drop it into the form component.
  6. Double-click stringItem inside the Screen Designer. Delete the stringItem title and type Press Exit to close application.

    Screen view with a stringitem

Changing the Timeout Property of the SplashScreen Component

  1. Choose Flow at the top of the Visual Mobile Designer window to return to the Flow view.
  2. Select the splashScreen component.
  3. In the Properties window find the Timeout property and change it from 5000 to 10000 milliseconds.

    Properties window for the splashScreen component

Adding the Exit Command to the Form Component

Choose the Exit Command from the Commands section of the Palette, and drag it into the form component.

Exit command added to the form component

Adding an Image Resource

  1. Copy a *.png file to the $PROJECTHOME/src/splashscreenexample folder.
  2. Right-click the splashScreen component and choose Properties in the popup menu.
  3. In the Properties dialog box, click the ellipsis button (Ellipsis button) against the Image property.
  4. In the Image dialog box, click Add.
    The image1 component is added.
  5. Click Browse and in the Open dialog box specify the path to the copied *.png file.
    The image is added.

    Screen view with a stringitem

  6. Click OK to close the Open dialog box.
  7. Click Close to close the Properties dialog box.
    The image is bound to the splashScreen component.
  8. In the Flow Designer, double-click the splashScreen component to open the Splash Screen in the Screen Designer.
    It should look like the folowing screen:

    Splash screen with an image and text

Connecting Components

In the Flow view, on Started on the Mobile Device and drag it to the splashScreen component. In the same manner, connect the components as shown in the following graphic.

Flow view

Running the Project

Press F6 to run the project. Alternatively you can select Run > Run Project from the main menu.
As the application runs, an emulator window opens and displays the application running in the default device emulator.

Emulator displays the splash screen of the application

top

Javadoc for the SplashScreen Component

The NetBeans IDE provides API Javadocs for the SplashScreen component, as well as other components you can use in the Visual Mobile Designer. To read the Javadocs for the SplashScreen component:

  1. Place the cursor on the SplashScreen component in the source code and press Ctr-Shift-Space (or choose Source > Show Documentation).
    The Javadoc for this element displays in a popup window.

    Javadoc for SplashScreen

  2. Click the Show documentation in external web browser icon (Show documentation in external web browser) in the popup window to view the detailed information about the SplashScreen component in your browser.

top

See Also

top

get support for the NetBeans

Support


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2015, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo