Problem in Midletsuite.....
I am beginner in J2ME.... While learning [B]Midlet suite[/B] from tutorial link - [url]http://www.j2mesalsa.com/elearning/MIDP.html[/url]... I downloaded three programs from that link which are as follows....
[B]FirstMIDlet.java :-[/B]
package com.j2me.salsa.midletsuite;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public class FirstMIDlet extends MIDlet
{
public FirstMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 1", this);
Display.getDisplay(this).setCurrent(helloForm);
}
protected void startApp() {}
protected void pauseApp() {}
protected void destroyApp(boolean bool) {}
}
[B]SecondMIDlet.java :-[/B]
package com.j2me.salsa.midletsuite;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public class SecondMIDlet extends MIDlet
{
public SecondMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 2", this);
Display.getDisplay(this).setCurrent(helloForm);
}
protected void startApp() {}
protected void pauseApp() {}
protected void destroyApp(boolean bool) {}
}
[B]ThirdMIDlet.java :-[/B]
package com.j2me.salsa.midletsuite;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public class ThirdMIDlet extends MIDlet
{
public ThirdMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 3", this);
Display.getDisplay(this).setCurrent(helloForm);
}
protected void startApp() {}
protected void pauseApp() {}
protected void destroyApp(boolean bool) {}
}
[B]HelloWorldForm.java:-[/B]
package com.j2me.salsa.midletsuite;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
public class HelloWorldForm extends Form implements CommandListener
{
private Command exitCommand;
MIDlet midlet;
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);
}
public void commandAction(Command cmd, Displayable disp) {
if (cmd == exitCommand) {
midlet.notifyDestroyed(); // Midlet notifies the AMS that it has done its work.
}
}
}
From the above stuff..... i have to access FirstMIDlet, SecondMIDlet, ThirdMIDlet from HelloWorldForm program & i want to done this by running HelloWorldForm program. According to me,Constructor of HelloWorldForm have to access that all three classes but this is giving me error which is as follows :-
Unable to create MIDlet com.j2me.salsa.midletsuite.HelloWorldForm
java.lang.IllegalAccessException
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Selector.run(+22)
How should I resolve this problem?????
Re: Problem in Midletsuite.....
[QUOTE=Rahul More;907973]I am beginner in J2ME.... While learning [B]Midlet suite[/B] from tutorial link - [url]http://www.j2mesalsa.com/elearning/MIDP.html[/url]... I downloaded three programs from that link which are as follows....
[B]FirstMIDlet.java :-[/B]
package com.j2me.salsa.midletsuite;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public class FirstMIDlet extends MIDlet
{
public FirstMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 1", this);
Display.getDisplay(this).setCurrent(helloForm);
}
protected void startApp() {}
protected void pauseApp() {}
protected void destroyApp(boolean bool) {}
}
[B]SecondMIDlet.java :-[/B]
package com.j2me.salsa.midletsuite;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public class SecondMIDlet extends MIDlet
{
public SecondMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 2", this);
Display.getDisplay(this).setCurrent(helloForm);
}
protected void startApp() {}
protected void pauseApp() {}
protected void destroyApp(boolean bool) {}
}
[B]ThirdMIDlet.java :-[/B]
package com.j2me.salsa.midletsuite;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
public class ThirdMIDlet extends MIDlet
{
public ThirdMIDlet() {
HelloWorldForm helloForm = new HelloWorldForm("Hello World From Midlet 3", this);
Display.getDisplay(this).setCurrent(helloForm);
}
protected void startApp() {}
protected void pauseApp() {}
protected void destroyApp(boolean bool) {}
}
[B]HelloWorldForm.java:-[/B]
package com.j2me.salsa.midletsuite;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.midlet.MIDlet;
public class HelloWorldForm extends Form implements CommandListener
{
private Command exitCommand;
MIDlet midlet;
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);
}
public void commandAction(Command cmd, Displayable disp) {
if (cmd == exitCommand) {
midlet.notifyDestroyed(); // Midlet notifies the AMS that it has done its work.
}
}
}
From the above stuff..... i have to access FirstMIDlet, SecondMIDlet, ThirdMIDlet from HelloWorldForm program & i want to done this by running HelloWorldForm program. According to me,Constructor of HelloWorldForm have to access that all three classes but this is giving me error which is as follows :-
Unable to create MIDlet com.j2me.salsa.midletsuite.HelloWorldForm
java.lang.IllegalAccessException
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Selector.run(+22)
How should I resolve this problem?????[/QUOTE]
The example whatever being given in the link is for showing how a midlet suite can have many midlets in it , as a midlet itself cant display anything for each midlet the same form is being used as the ui . Here helloform is not a midlet , so if you try to run there wont be any result .
In j2me the displayable(form) itself cant run anything .,like main in java -- > midlet is the starting point of execution so only he has called the form in the midlet. so try to run the application as -- >Emulated Java ME JAD . then you can see the three midlets in a list for execution . Hope this will resolve your problem
Re: Problem in Midletsuite.....
Ok.........Thanx to help me.......Thanx a lot Venkatesh.....