开发者

using lwuit UI library I am not destroy j2me application

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.MID开发者_开发知识库let;

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 

}


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();
               }
            });
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜