我可以在应用程序中同时使用画布和表单吗

发布于 2024-11-16 07:29:11 字数 60 浏览 5 评论 0原文

我可以在应用程序中同时使用 Canvas 和 form 吗?如果是,那么我如何从 Canvas 访问表单?

Can I use Canvas and form together in application? If yes then how can I access form from Canvas?

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

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

发布评论

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

评论(3

梦幻的心爱 2024-11-23 07:29:11

是的,您可以同时使用两者,但不能同时使用。您可以使用 Display.setCurrent()

Yes you can use both but not at the same time. You can switch between them by using Display.setCurrent().

旧时光的容颜 2024-11-23 07:29:11

您需要 Midlet 来找到其显示(和表单)。您需要将 MIDlet 的引用发送到画布构造函数。因此您的画布将如下所示:

class myCanvas extends Canvas implements ... {
myMIDlet myHost; // the breadcrumb

    public myCanvas(... , myMIDlet host) {
    myHost = host; // remember our host MIDlet
    ...
    }

    ...
}   

其中“myMIDlet”是您的 MIDlet 的名称。
在您的 MIDlet 中:

public class myMIDlet extends MIDlet implements ... {
...
Form myForm = new Form( ... 
...
myCanvas ggg = new myCanvas(... , this) // <=== note the last parameter-the key to it all
...   
//switch display to myCanvas
display.setCurrent(ggg);
...
}

当您想要从“myCanvas”访问表单(可能在画布的 commandAction 或 keyPressed 方法中)时,请执行以下操作:

Display disp = myHost.getDisplay();
disp.setCurrent(myHost.myForm);

参考:
代码项目

You need your Midlet to find its display (and the form).You would to send a reference of your MIDlet to the canvas constructor.So your canvas would be look like this:

class myCanvas extends Canvas implements ... {
myMIDlet myHost; // the breadcrumb

    public myCanvas(... , myMIDlet host) {
    myHost = host; // remember our host MIDlet
    ...
    }

    ...
}   

Where "myMIDlet" is name of your MIDlet.
In your MIDlet:

public class myMIDlet extends MIDlet implements ... {
...
Form myForm = new Form( ... 
...
myCanvas ggg = new myCanvas(... , this) // <=== note the last parameter-the key to it all
...   
//switch display to myCanvas
display.setCurrent(ggg);
...
}

When you want to got to the form from "myCanvas" (probably in a commandAction or keyPressed methods of your canvas) do this:

Display disp = myHost.getDisplay();
disp.setCurrent(myHost.myForm);

Reference:
codeproject

蹲在坟头点根烟 2024-11-23 07:29:11

您可以将表单切换为画布。例如:

        canvasName c=new canvasName(this);
        Display.getDisplay(this).setCurrent(c);

但是,在 Canvas to Form 中,我不知道。

You can switch form to canvas. For example:

        canvasName c=new canvasName(this);
        Display.getDisplay(this).setCurrent(c);

But, in Canvas to Form, I don't know.

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