2011-04-03 69 views
0

我使用LWUIT J2ME工作,我有一個問題是,使用LWUIT UI庫,我不會破壞J2ME應用程序

當我startApp()裏面的MIDlet我第一次Display.init(this)

和運行應用程序LWUIT工作好但是當我在MIDlet的利用內幕startApp()事件的形式,它很好的工作,但這種形式的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 

} 
+0

你添加的命令?我不明白你的編碼?這是完整的你的代碼? – bharath 2011-04-04 06:13:01

+0

雅我添加命令我的問題是,當mainMiddlet啓動可以從另一個形式的命令事件上面在我的代碼destory我有mainmiddlet我添加一個命令下一個,當我按下它移動另一個窗體(新窗體),但從那裏我可以不回到mainMiddlet它拋出錯誤java.lang.error.nullpointherException – 2011-04-04 13:39:17

回答

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

嗨感謝您的考慮但是,當我呼籲form.show()這是對象擴展midlet類,所以當我按下新形式後退命令,你在上面的代碼中提到它會拋出異常java.lang.nullpointe異常請幫幫我.............. – 2011-04-05 18:34:00

+1

發佈您的NewForm.java代碼。 – bharath 2011-04-06 05:05:13

相關問題