|
|
| | Terms of Agreement:
By using this article, you agree to the following terms...
1) You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description. |
Creating a Game or Application for your Cellphone
by Ralf Kistner
To create a game or application for your cellphone, you need the following:
- Jdk1.3 or higher
- J2ME Wireless Toolkit
- Any java or text editor
- A java-compatible cellphone (optional)
Creating a basic application that displays a string
Step 1: In J2ME Wireless Toolkit, create a new project. Give the project any name you want. Make the class name 'Main'. In the next screen, the only thing you need to change is the icon under the MIDlets tab. If you don't have a .png (Portable Network Graphics) icon, clear the icon field.
Step 2: Create [J2ME home dir]\apps\[project name]\src\main.java and place the following code in it:
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Canvas;
public class Main extends MIDlet {
private Canvas display;
public Main () {
display = new Display ();
}
public void startApp () {
Display.getDisplay (this).setCurrent (display);
}
public void destroyApp (boolean b) { }
public void pauseApp () { }
}
Step 3: Create [J2ME home dir]\apps\[project name]\src\Picture.java and place the following code in it:
import javax.microedition.lcdui.*;
public class Display extends Canvas {
Image img = Image.createImage (getWidth (), getHeight ());
Graphics graphics = img.getGraphics ();
public Display () {
graphics.drawString ("Just a String", 0, 0, 0); //String,x,y,anchor
}
protected void paint (Graphics g) {
g.drawImage (img, 0, 0, 0); //Image,x,y,anchor
}
}
Step 4: In J2ME, build the project. If it doesn't give any errors, you can choose the device and run it. A frame with a cellphone in it should pop up. Click on the button under launch and you should see "Just a String".
Congratulations! You have just made your 1st cellphone application!
Step 5: To put it on your cellphone, you'll have to create a package (Project->Package->Create Package).
See your cellphone's manual for futher instructions on how to put it on your cellphone.
In a later tutorial i'll explain how to use Forms. For further information, see J2ME's documentation.
If you read this tutorial, please support it by voting. It takes less than a minute of your time.
| | Other 2 submission(s) by this author
| | | Report Bad Submission | | | Your Vote! |
See Voting Log | | Other User Comments | 7/23/2002 7:22:41 AM:ElChico I wanted to do something like this. Now
I only need to get a cell phone that
will support Java and Capunnn.
| 7/23/2002 10:16:34 AM:Jose M Serrano Excellent, now I will be able to learn
wireless applications. Thanks for
sharing it. 5 beans
| 7/31/2002 3:47:02 PM:Rafal Krolik This is excellent tip. Any idea off the
top which phones support Java?
| 8/21/2002 11:27:50 AM:Tim McNally In step 3, shouldn't Picture.java be
named Display.java?
| 9/6/2002 7:54:23 AM: The new Nextel phones support Java.
| 9/12/2002 3:16:14 PM:R Kistner Sorry, it should be Display.java, not
Picture.java.
| | Add Your Feedback! | Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.
NOTICE: The author of this article has been kind enough to share it with you. If you have a criticism, please state it politely or it will be deleted.
For feedback not related to this particular article, please click here. | | |