Java ME help displaying calendar canvas from Nokia tutorial

浪尽此生 提交于 2019-12-14 03:28:31

问题


I've been following below tutorial on how to create a calendar widget in Java ME. I can't seem to get it to work.

When I run the application it just says it's running in the background. I guess I'm not initializing it properly. Where exactly to put the code located at the bottom of the page to make it display to the java phone screen?

The link to the tutorial is here apart from a few minor variable name differences the code is identical.

http://www.developer.nokia.com/Community/Wiki/Building_a_Java_ME_Canvas_based_calendar/date_picker


回答1:


...it just says it's running in the background. I guess I'm not initializing it properly.

Without seeing your code it's hard to tell for sure but assuming that you did not introduce errors copying tutorial code, the most likely reason for the behavior like you describe is that you didn't invoke Display.setCurrent. This would indeed qualify as not initializing it properly.

In the class that extends MIDlet, make sure that startApp invokes setCurrent, like as below:

public void startApp() {
    Display.getDisplay(this).setCurrent(
            new CalendarCanvas(this));
}

Note in code snippet above, CalendarCanvas is assumed to be as per tutorial you refer to:

- CalendarCanvas.java: sample usage of CalendarWidget within a Canvas...



来源:https://stackoverflow.com/questions/10364705/java-me-help-displaying-calendar-canvas-from-nokia-tutorial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!