0

我正在使用 lwuit 使用 j2me 我有一个问题是

当我startApp()在 midlet 里面时,我首先设置Display.init(this)

并运行应用程序 lwuit 工作良好,但是当我在 midlet 中使用 Form inside startApp()event 时,它工作良好,但是在这种形式 actionevent 中,我调用了新形式,在这种新形式中,当我按下它时,我放了一个返回命令,它不会在主 midlet 上移动

请帮助如何知道 lwuit 使用

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 

}
4

1 回答 1

0

它很简单。show()您可以在下一个表单返回命令中调用该方法。例如,

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

新窗体.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();
               }
            });
    }
于 2011-04-04T14:01:14.820 回答