简体   繁体   English

代号一个动作监听器不起作用

[英]Codename one actionlistener not working

I'm currently working on building my first app.我目前正在构建我的第一个应用程序。 :) I've now coded several Forms, each in an own class. :) 我现在已经编写了几个表单,每个表单都在一个自己的类中。 Now, I want to implement the navigation from one Form to another, this is pretty straight forward since there is always only one "next" Form for every Form currently.现在,我想实现从一个表单到另一个表单的导航,这非常简单,因为当前每个表单总是只有一个“下一个”表单。

So i tried to do this by adding a "nextForm" Form to every Class and I want nextForm.show() every time the "next" Button is pressed.所以我试图通过向每个类添加一个“nextForm”表单来做到这一点,并且每次按下“next”按钮时我都想要 nextForm.show() 。 I tried it this way:我是这样试的:

login = new Button("Login");
    login.setUIID("nxtButtons");
    login.addActionListener((e) ->
            nextForm.show()
    );

So, when i actually click the button, nothing happens.所以,当我真正点击按钮时,什么也没有发生。

Is the way I try to code this a good way?我尝试编码的方式是一种好方法吗? This is the first time Im heading into GUI building and I don't have experience here yet.这是我第一次进入 GUI 构建领域,我还没有这方面的经验。 Maybe one of you guys could help me here :)也许你们中的一个人可以在这里帮助我:)

Thank you very much非常感谢

Kind regards,亲切的问候,

Max最大限度

I'm assuming nextForm is null and you should see the null pointer exception in the console somewhere.我假设nextFormnull ,您应该在控制台的某处看到空指针异常。

If not nextForm might be pointing at the current form which will do nothing.如果不是nextForm可能指向当前的表单,它什么也不做。 You can place a break point on that line in the debugger and see that the break point is reached then inspect the values of the variables.您可以在调试器中的该行上放置一个断点,查看是否到达断点,然后检查变量的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM