0

I am working with j2me using lwuit I have one problem is that

when I am startApp() inside midlet I first set Display.init(this)

and run application lwuit work good but when I am using Form inside startApp() event in midlet it good work but in this form actionevent I am call new form and in this new form I put one back command when I pressed it it does not move on main midlet

please help how know lwuit use

import javax.microedition.MIDlet;

import  some lwuit UILibrary

public class mainMiddlet extends MIDlet implement ActionListner
{
      public mainMiddlet(){
                  try{

                       Display.init(this);
                       //somthing is here 
                       form=new Form();

                       form.addActionListener(this);

                     }catch(Exception e){}
       }
       public void actionperformed(ActionEven ae){
                //here i call new form 
                //in action event of this form 
                new form().show();
        }
       //here some middlet default method 


}
public class newForm extends Form {

    //in this form I am put one command back and when i am pressed it 
    // I call mainMiddlet but it throw error internal application java.lang.nullpointer
   // can I back on mainmiddlet from on form to another form 
   // my main problem is I am not move on mainmiddlet for exit middlet because destoryall()
   // is method of middlet 

}
gnat
  • 6,213
  • 108
  • 53
  • 73
Bhavdip Sagar
  • 1,951
  • 15
  • 27
  • Did you add the command? I dont understand your coding? Is this full of your code? – bharath Apr 04 '11 at 06:13
  • ya i add command my problem is that when mainMiddlet start can i destory from another form command event above in my code i have mainmiddlet i add one command Next and when i pressed it move on another form(new form)but from there i can not back on mainMiddlet it throws error java.lang.error.nullpointherException – Bhavdip Sagar Apr 04 '11 at 13:39

1 Answers1

0

Its just simple. You can call the show() method inside next form back command. For example,

MainMidlet.java

// create the midlet and write inside of the midlet
final Form form = new Form();

form.addCommand(new Command("Next") {

    public void actionPerformed(ActionEvent evt) {
            new NewForm(form).show();
       }
    });

NewForm.java

   // create the NewForm class and write inside of the class

        public NewForm(final Form form) {
   // Constructor
        addCommand(new Command("Back") {

            public void actionPerformed(ActionEvent evt) {
                    form.show();
               }
            });
    }
bharath
  • 14,283
  • 16
  • 57
  • 95
  • Hi Thank for consideration But When i call form.show() which is object extends midlet class so when i pressed in new form back command as you mention in above code it will throw exception java.lang.nullpointe Exception Please Help Me .............. – Bhavdip Sagar Apr 05 '11 at 18:34