使用 lwuit UI 库我不会破坏 j2me 应用程序

发布于 2024-10-29 02:57:35 字数 1358 浏览 3 评论 0原文

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

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

并运行应用程序 lwuit 工作良好但是当我在 midlet 中的 startApp() 事件中使用 Form 时,效果很好,但是在这个表单中,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 

}

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 

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无所的.畏惧 2024-11-05 02:57:35

很简单。您可以在下一个表单返回命令中调用 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();
               }
            });
    }

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();
               }
            });
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文