Create a simple J2ME program with EclipseME0.5.5

Source: Internet
Author: User
Tags stub
Program | Create a simple J2ME program with EclipseME0.5.5

In the previous article how to install Eclipseme 0.5.5 on Eclipse3.0.1, we have talked about how to install the Eclipse program on Eclipse3.0.1.
Today we are going to use him to create our first program. The first program in most program tutorials is called HelloWorld. So let's make up a HelloWorld program.

1, File
2, New project
3, select J2me,j2me Midlet Suite
4, enter project name: MYFIRSTJ2ME
5, select J2ME Wireless Toolkit 2.1 MIDP 1.0 platform (where MIDP 2.0 can also be selected, but the current direct MIDP 2.0 mobile phone is still a small number, can be queried: http://jal.sun.com/webapps/ Device/device)

Java build defaults, and then click Finish to complete the basic setup of the J2ME project.


After the steps are complete, you will see the following interface:



È file

È new Other

È select J2me,j2me Midlet

È

Click Next to enter the new J2ME Midlet program. Enter the name at: HelloWorld. Then click Finish and the system will automatically generate some code. as shown below.




È we've added one or two words to the eclipse-generated program, we can do the simplest program of HelloWorld.

Import Javax.microedition.midlet.MIDlet;
Import javax.microedition.midlet.MIDletStateChangeException;
/*
* Created on 2004-10-21
*
* TODO to change the template of this generated file go
* Window-preferences-java-code Style-code Templates
*/

/**
* @author Administrator
*
* TODO to change the template of this generated type comment go
* Window-preferences-java-code Style-code Templates
*/
public class HelloWorld extends MIDlet {
Private textbox textbox; New
/**
*
*/
Public HelloWorld () {
Super ();
TextBox = new TextBox ("HelloWorld", "Hello, Welcome to J2ME World!", 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

}

}

From the above, these automatically generated code from eclipse can see that these are the basic frameworks for J2ME midlet programs. Look, is it like the applets in Java?

For example, each applet inherits the applet class, has a start (), a Stop (), Destroy (), and other methods.

And each MIDlet program inherits Javax.microedition.midlet.MIDlet class, has Startapp (), Pauseapp (), Destoryapp () and other methods.

È run



È Finally, the program automatically invokes the emulator, as shown below



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.