To make developing eSWT MIDlets faster and easier, the Java Developer's
Library provides an eSWT MIDlet starter, consisting of two classes,
that you can use as a basis for implementing MIDlets with eSWT UIs.
The starter creates the eSWT UI thread and also manages the MIDlet
lifecycle for you. If supported by the device, the starter uses the org.eclipse.ercp.swt.midp.UIThreadSupport
class to safely
obtain a platform-optimized thread for the eSWT UI. Otherwise, the
starter creates a random thread for the UI.
To create an eSWT MIDlet using the eSWT MIDlet starter:
Download the eSWT MIDlet starter and extract the files.
Include the
files SWTMIDlet.java
and UIThreadSupportWrapper.java
in your MIDlet project. If you are using Eclipse or NetBeans, copy
the files to folder <IDE Projects>\<MIDlet>\src\
.
Note: If you include these files in a Java package other than the default one, add the appropriate package declaration to both files and import the package accordingly in the MIDlet main class.
Set the MIDlet
main class to extend SWTMIDlet
.
In the MIDlet
main class, implement either the SWTMIDlet.runMain
or SWTMIDlet.runUI
method:
If you want to create the Display
and event
loop for the MIDlet yourself, implement the SWTMIDlet.runMain
method.
If you want the starter to create the Display
and event loop for the MIDlet, implement the SWTMIDlet.runUI
method.
For more information about the Display
and
event loop requirements for eSWT MIDlets, see section Using eSWT.
Create the UI for your MIDlet. Note the following:
If your MIDlet implements the SWTMIDlet.runMain
method, you must first create the Display
and event
loop for the MIDlet, and then create the UI components on the Display
.
If your MIDlet implements the SWTMIDlet.runUI
method, you only need to create the UI components. The starter handles
the Display
and event loop.
For more information about the eSWT MIDlet starter implementation,
see the files SWTMIDlet.java
and UIThreadSupportWrapper.java
.
For an example MIDlet that implements the SWTMIDlet.runUI
method, see section Example: Hello World in eSWT.