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.
Contents
Requirements
To complete this tutorial, you need the following software and resources:
Installing and Running the Sample Application
Before we begin, you might want to see final result of the tutorial.
Take the following steps to install SplashScreen example application:
- Download
SplashScreen.zip.
- Unzip the file.
- In the IDE, choose File > Open Project and find the folder that contains the unzipped file.
- Open the Project. It should look like the following:
- In the Projects window, right-click the project node and choose Run Project
(or press F6 key). As the application runs, an emulator window opens and
displays the application running in the default device emulator.
- In the Emulator window, click the button underneath "Launch." The emulator displays a splash screen, as shown:

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:
- Create the SplashScreen project
- Add packages and a Visual MIDlet to the project
- Add components to MySplashScreenMidlet
- Change the Timeout property of the SplashScreen component
- Add Exit and Back commands to the Form component
- Add images to the splash screen
- Connect the components
- Run the project
Creating the SplashScreen Project
- Choose File > New Project (Ctrl-Shift-N). Under Categories, select
Java ME. Under Projects, select Mobile Application and click Next.
- Enter
SplashScreenExample in the Project Name field. Change
the Project Location to a directory on your system. This directory is called $PROJECTHOME.
- Uncheck the Create Hello MIDlet checkbox. Click Next.
- Leave the Sun Java Wireless Toolkit 2.52 as the selected Emulator Platform. Click
Finish.
Adding Packages and a Visual MIDlet
to the Project
- 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.
- Enter
splashscreenexample in the Package Name field. Click Finish.
- 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.
- Enter
MySplashScreenMIDlet into MIDlet Name and MIDP Class Name fields. Click Finish.
Adding Components to MySplashScreenMidlet
- Switch your Visual MIDlet to the Flow window. Drag the following
Screen components from the Palette and drop them in the Flow Designer:
- The Splash Screen component when viewed in the Flow Designer:

- Select the splashScreen1 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.
- Select the form component to and change its Title property to
Form.
- Double-click the form component in the Flow window to switch
to the Screen Designer
- Select the StringItem component from the Form Items section of the Palette,
then drag and drop it into form1.
- Double-click stringItem1 inside Screen Designer. Delete the title("stringItem1")
and change
<Enter Text> to Press Exit to close
application.
Changing the Timeout Property of the SplashScreen Component
- Choose Flow at the top of the Visual Mobile Designer window to re-open the Flow Design view.
- Select the Splash Screen component.
- In the Properties Window find the Timeout property and change it from
5000 to 10000 milliseconds.
Adding Exit and Back Commands to the Form Component
-
Choose the Exit Command from the Commands section in the Palette, and
drag it into the form1 component.
Adding an Image Resource
-
Copy the splash.png file
to the
$PROJECTHOME/src/splashscreenexample folder.
- Right-click the Resources in the Project Window and choose Add >
Image.
-
Choose Add option from popup menu and then Image.
- Select
image1 in the Project Window.
- In the Properties Window, choose the Resource Path and then choose splash.png.
Binding an Image to a Component
- Select the splashScreen1[SplashScreen] component.
- In the Properties Window, use the drop-down menu to change the Image
property to image1.
Double-click the component to open the splash screen in the Screen Designer.
It should look like the folowing screen.

Connecting Components
-
In the Flow view, click on the Start Point and drag the arrow
to the splashscreen1 component. In the same manner, connect the components
as shown in the following graphic.

Running the Project
-
Press <F6> to Run the main project.
Alternatively you could select Run > Run Main Project.
Additional NetBeans Java ME Custom Component Tutorials