Creating the Midlet
The last tutorial showed you how to use Netbeans IDE to create a basic MIDP 2.0 MIDlet, compile it, and preview your program in the emulator. Unfortunately, the code generated for the Hello MIDlet is of little or no use for making games. So in this tutorial you will be shown the basic code needed for creating your games.
First off, open Netbeans and create a new mobile application project. What we need is a blank project so remember to uncheck the "Create Hello MIDlet" on the "Name and Location" screen.
Now we need to create the MIDlet ourselves. There are several ways to go about this.
- By pressing CTRL+N on your keyboard.
- By choosing New File from the File Menu
- By right-clicking on the project panel treeview and selecting New, then Midlet
For those of you who used one of the first 2 ways, select MIDP from the categories and MIDlet from the list of file types then click on the "Next" button.
On the next screen, type in midMain for MIDlet Name. The MIDlet Class Name field will be automatically filled in for you. Leave the MIDlet icon blank for now. As a rule of thumb, never create your files in the "default package". Enter MyGame in the Package field. A folder with the same name will be created inside the project source folder where all source code for your game should go. Click on the "Finish" button.
Congratulations!! You have succeeded on creating an empty MIDlet that does absolutely nothing. Next stop, Creating the Canvas...