诺基亚 E72 上的 J2ME 中的 LWUIT 问题

发布于 2024-09-04 03:58:11 字数 1215 浏览 3 评论 0原文

好吧,我正在手机中开发一个要连接到我的 PC 的应用程序,问题是每次我向手机返回 URLRequest 时,它都会在屏幕上显示上一个表单,而不是实际的表单,例如这就是我的actionListener中的内容:

public void actionPerformed(ActionEvent ae) {
    if (ae.getCommand() == guiaUtil.cSelecionar()) {
        LoginRemote loginRemote = new LoginRemote();

        try {
            //This is the request, returns true or false, does not affect the form
            loginRemote.login(tLogin.getText(), tPassword.getText());
        } catch (Exception e) {

            GuiaUtil.error(e);
            return;
        }
        guiaUtil.mainApp().startMenu();
    }

}

然后在“guiaUtil.mainApp().startMenu()”中我有这个

public void startMenu() {
    if (itemsMenu == null) {
        itemsMenu = new List();
        itemsMenu.setWidth(320);

        itemsMenu.addItem("Sincronize Spots");
        itemsMenu.addItem("Find Spots");
        itemsMenu.addItem("Work");
        itemsMenu.setFocus(true);

        this.addComponent(itemsMenu);
        this.addCommandListener(this);
        this.addCommand(guiaUtil.cSelect());
        Form form = new Form();
        form.addComponent(itemsMenu);

    }
    form.show();

}

无论如何,在请求返回后,它再次显示我的登录表单,而不是显示菜单列表

Well, I'm developing a app in my cellphone that is going to connect to my PC, the problem is that everytime that I return a URLRequest to the cellphone, it shows the previous Form on the screen and not de actual one, for example this is what goes in my actionListener:

public void actionPerformed(ActionEvent ae) {
    if (ae.getCommand() == guiaUtil.cSelecionar()) {
        LoginRemote loginRemote = new LoginRemote();

        try {
            //This is the request, returns true or false, does not affect the form
            loginRemote.login(tLogin.getText(), tPassword.getText());
        } catch (Exception e) {

            GuiaUtil.error(e);
            return;
        }
        guiaUtil.mainApp().startMenu();
    }

}

Then in the "guiaUtil.mainApp().startMenu()" I have this

public void startMenu() {
    if (itemsMenu == null) {
        itemsMenu = new List();
        itemsMenu.setWidth(320);

        itemsMenu.addItem("Sincronize Spots");
        itemsMenu.addItem("Find Spots");
        itemsMenu.addItem("Work");
        itemsMenu.setFocus(true);

        this.addComponent(itemsMenu);
        this.addCommandListener(this);
        this.addCommand(guiaUtil.cSelect());
        Form form = new Form();
        form.addComponent(itemsMenu);

    }
    form.show();

}

Anyway, after the request returns, it shows my Login form again, instead of showing the Menu List

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

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

发布评论

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

评论(3

没有伤那来痛 2024-09-11 03:58:11

也许发生的情况是您遇到异常,用 GuiaUtil.error 处理它并从 actionPerformed 返回,而不调用 startMenu
我会将 guiaUtil.mainApp().startMenu() 移动到 try/catch 块内。

Maybe what is going is that you are getting an exception, treating it with GuiaUtil.error and returning from actionPerformed without calling startMenu.
I would move guiaUtil.mainApp().startMenu() inside the try/catch block.

倾`听者〃 2024-09-11 03:58:11

不确定 loginRemote.login(tLogin.getText(), tPassword.getText()); 中会发生什么情况
如果您访问网络,我会将该部分放在不同的线程中。
当“远程登录”完成时,通过某种回调通知主线程,
然后您可以从 edt 显示 menuForm 。

Not sure what happens in loginRemote.login(tLogin.getText(), tPassword.getText());
If you access the network, I would put that part in a different thread.
Inform the main thread by some kind of callback when the "remote login" is done,
you can show the menuForm from the edt then.

眼角的笑意。 2024-09-11 03:58:11

您必须将以下代码放在 if 条件之外。

Form form = new Form();
form.addComponent(itemsMenu);

您有两个表单对象。一个在 if 内部,另一个在 if 外部。在循环内创建的对象将失去 if 内的范围。您正在 if 之外显示表单对象。这就是为什么菜单列表屏幕没有显示。

You have to put the following code outside the if condition.

Form form = new Form();
form.addComponent(itemsMenu);

You are having two form object. one inside if and another one outside of if. Object created inside the loop will loses the scope inside if. You are showing form object outside if. That's why, menu list screen was not displayed.

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