Create a simple J2ME program with Eclipseme0.5.5

xiaoxiao2021-03-06  110

Create a simple J2ME program with Eclipseme0.5.5

Author: chinamao-mail:

CHINAMAO@gmail.com Reprinted please indicate the source

related articles

The last article "How to install Eclipseme 0.5.5 on Eclipse 3.0.1", we have talked how to install the Eclipse program on Eclipse3.0.1. Today we have to use him to create our first program. The maximum number of program tutorials is called HelloWorld. Then let's compile a HelloWorld program. 1, Document 2, New Project 3, Select J2ME, J2ME MIDlet Suite4, Enter the project name: myfirstj2me5, select J2ME Wireless Toolkit 2.1 MIDP 1.0 Platform (you can also choose MIDP 2.0, but currently MIDP 2.0 mobile phone or a few mobile phones , Can query: http://jal.sun.com/webapps/device/device) Java build settings Default, then, click Finish to complete the basic settings of the J2ME project. After completing the above steps, you can see the following interface: è file è New Other è Select J2ME, J2ME MIDlet è Click Next to enter the new J2ME MIDLET program. Enter: HelloWorld at the name: HelloWorld. Then click Finish, and some code will automatically generate. As follows.

è We add one or two sentences in the program generated by Eclipse, you can do this the easiest program of HelloWorld.

import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; / * * Created on 2004-10-21 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates * /

/ ** * @author Administrator * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates * / public class HelloWorld extends MIDlet {private TextBox textbox; // add / ** * * / public helloWorld () {super (); TextBox = New TextBox ("HelloWorld", "Hello, welcome to J2ME!", 20, 0); // New // Todo Auto- Generated constructor stub}

/ * (Non-Javadoc) * @see javax.microedition.midlet.MIDlet # startApp () * / protected void startApp () throws MIDletStateChangeException {// TODO Auto-generated method stub Display.getDisplay (this) .setCurrent (textbox) ; // new}

/ * (non-javadoc) * @see javax.microedition.midlet.midlet # Pauseapp () * / protected void Pauseapp () {// Todo auto-generated method stub}

/ * (Non-Javadoc) * @see javax.microedition.midlet.MIDlet # destroyApp (boolean) * / protected void destroyApp (boolean arg0) throws MIDletStateChangeException {// TODO Auto-generated method stub

}

} Everyone is from above, these code automatically generated by Eclipse can be seen, these are the basic framework of the J2ME MIDLET program. Everyone looks, is it very similar to the applet in Java? For example, each applet program inherits the Applet class, there is START (), stop (). Destroy () and other methods. Each MIDlet program inherits the javax.microedition.midlet.midlet class, STARTAPP (), PauseApp (), DestoryApp ().

è run

è Finally, the program will automatically call the simulator, as shown below

related articles

转载请注明原文地址:https://www.9cbs.com/read-102914.html

New Post(0)