Java ME - 多种形式,从一个屏幕移动到下一个屏幕

发布于 2024-08-23 07:42:56 字数 150 浏览 5 评论 0原文

我正在使用 Java Micro Edition,我正在尝试使用记录存储创建一个简单的登录表单。当用户输入详细信息时,我想将其与存储的详细信息进行检查,然后移动到另一个屏幕(例如欢迎区域)。

我有一种感觉,它与表单元素及其之间的切换有关,但我似乎无法通过谷歌找到任何地方

I am using Java Micro Edition and I am trying to create a simple login form with a record store. When the user enters the details I'd like to check them against the ones stored and then move onto another screen like a welcome area.

I have a feeling it has something to do with the form element and switching between it but I can't seem to get anywhere with google

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

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

发布评论

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

评论(2

合久必婚 2024-08-30 07:42:56

试试这个

form = new Form("login");
form.addCommand(getExitCommand());
form.addCommand(getOkCommand());
form.setCommandListener(this);

public void commandAction(Command command, Displayable displayable) {
    if (displayable == form) {
        if (command == exitCommand) {
            exitMIDlet();
        } else if (command == okCommand) {
            display.setCurrent(getWelcomeForm());
        }
    } else if (displayable == form1) {
        if (command == backCommand) {
            // do something else
        }
    }
}

try this

form = new Form("login");
form.addCommand(getExitCommand());
form.addCommand(getOkCommand());
form.setCommandListener(this);

public void commandAction(Command command, Displayable displayable) {
    if (displayable == form) {
        if (command == exitCommand) {
            exitMIDlet();
        } else if (command == okCommand) {
            display.setCurrent(getWelcomeForm());
        }
    } else if (displayable == form1) {
        if (command == backCommand) {
            // do something else
        }
    }
}
再见回来 2024-08-30 07:42:56

display 是应该在构造函数中及其上方创建的内容,即

public class YourMidlet extends MIDlet implements CommandListener {

    private Display display;
    private Form form1;
    private Form form2;

    public YourMidlet 
    {
        display = Display.getDisplay(this);
        form 1 = new Form("hello form this is form 1");
        form 2 = new Form("hello form 2");
        display.setCurrent(form1);
    }

}

您然后执行以下操作:

display.setCurrent(form2);

切换到表单 2

display is something that should be created in the constructor and also above it i.e.

public class YourMidlet extends MIDlet implements CommandListener {

    private Display display;
    private Form form1;
    private Form form2;

    public YourMidlet 
    {
        display = Display.getDisplay(this);
        form 1 = new Form("hello form this is form 1");
        form 2 = new Form("hello form 2");
        display.setCurrent(form1);
    }

}

you then do:

display.setCurrent(form2);

to switch to form 2

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