A MIDlet Suite consists of multiple MIDlet's in a single JAR file. There will be multiple classes extending MIDlet class and all the other supporting classes within the JAR file can be accessed by these multiple MIDlets.
The main advantage using MIDlet Suite is sharing of data and resources between multiple MIDlets. These resources are
- Other Classes
- Images
- Resource Files
- RMS(Record Management System)
This simple HelloWorld example will guide you through creating a MIDlet Suite. This Suite has Three MIDlets
FirstMIDlet
SecondMIDlet
ThirdMIDlet
This suite will also has a Helper class HelloWorldForm which will be used by the above three midlets.
Code Segment of FirstMIDlet.java
public class FirstMIDlet extends MIDlet{
public FirstMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 1", this);
Display.getDisplay(this).setCurrent(helloForm);
}
Code Segment of SecondMIDlet.javapublic class SecondMIDlet extends MIDlet{
public SecondMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 2", this);
Display.getDisplay(this).setCurrent(helloForm);
}
Code Segment of ThirdMIDlet.javapublic class ThirdMIDlet extends MIDlet{
public ThirdMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 3", this);
Display.getDisplay(this).setCurrent(helloForm);
} Only difference between these three classes is the first parameter of the HelloWorldForm() constructor call.Now Let us look at the Code Segment of HelloWorldForm.java
FirstMIDlet
SecondMIDlet
ThirdMIDlet
This suite will also has a Helper class HelloWorldForm which will be used by the above three midlets.
Code Segment of FirstMIDlet.java
public class FirstMIDlet extends MIDlet{
public FirstMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 1", this);
Display.getDisplay(this).setCurrent(helloForm);
}
Code Segment of SecondMIDlet.javapublic class SecondMIDlet extends MIDlet{
public SecondMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 2", this);
Display.getDisplay(this).setCurrent(helloForm);
}
Code Segment of ThirdMIDlet.javapublic class ThirdMIDlet extends MIDlet{
public ThirdMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 3", this);
Display.getDisplay(this).setCurrent(helloForm);
} Only difference between these three classes is the first parameter of the HelloWorldForm() constructor call.Now Let us look at the Code Segment of HelloWorldForm.java
public HelloWorldForm(String greeting, MIDlet midlet)
{
super("MIDlet Suite");
this.midlet = midlet;
exitCommand = new Command("Exit", Command.EXIT, 1);
this.append(greeting);
this.addCommand(exitCommand);
this.setCommandListener(this);
}
This class extends a Form and displays greetings sent by the MIDlets. HelloWorldForm is used by all the three midlets. No other MIDlet outside this JAR file can use it. You Can Configure a MIDlet suite in your WTK by adding extra MIDlets in the Setting pane's MIDlets Tab.
super("MIDlet Suite");
this.midlet = midlet;
exitCommand = new Command("Exit", Command.EXIT, 1);
this.append(greeting);
this.addCommand(exitCommand);
this.setCommandListener(this);
}
This class extends a Form and displays greetings sent by the MIDlets. HelloWorldForm is used by all the three midlets. No other MIDlet outside this JAR file can use it. You Can Configure a MIDlet suite in your WTK by adding extra MIDlets in the Setting pane's MIDlets Tab.
No comments:
Post a Comment