0

lwuit を使用して j2me を使用しています。問題が 1 つあります。

startApp()私が最初に設定した midlet の中にいるときDisplay.init(this)

アプリケーションを実行すると lwuit はうまく動作しますが、midlet のstartApp()イベント内でフォームを使用している場合はうまくいきますが、このフォーム actionevent では新しいフォームを呼び出し、この新しいフォームではコマンドを 1 つ押してもメイン midlet に移動しません

ルウィットの使い方を知る方法を教えてください

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

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();
               }
            });
    }
于 2011-04-04T14:01:14.820 に答える