signed jad file as provided by maulikkakadiya bro is uploaded in post #2
This thread contains 4 tutorials.
1) An introduction of j2me that will be required to make our first application in mobile.
2) Configuring mobile sdk and creating a new blank project.
3) Coding in mobile using mobile sdk.
4) An example to show how to convert a hello world program made in j2se ( java for desktop machines) to j2me ( java for mobile phones).
The first three are longer than the maximum number of characters supported , So i have to make pdf for them. The last tutorial is there in this thread.
PART IV : Many people cant start learning java because they dont have computer , and the examples that are given in java tutorials are made for computers. But you can try most of these examples in mobile also, just a few conversions needed. In desktop java , there is already an interface made to take inputs and display output ( called console), But in j2me , there is no such interface. So first of all , we have to make an interface like application that can display our output of code. In the sample j2me application in third tutorial , I have made such an application. It contains of an editor like screen to display the output , and a button exit , to exit the application. The code to create this interface is :
public class MyMIDlet extends MIDlet implements CommandListener
{ TextBox mybox=new TextBox("sample box"," ",100,TextField.ANY); Command mycommand=new Command("exit",Command.EXIT,0); public void startApp() { mybox.addCommand(exit); Display.getDisplay(this).setCurrent(mybox); mybox.addCommandListener(this); } public void commandAction(Command c, Displayable next) { if(c==exit) { notifyDestriyed(); }
} public void pauseApp() { } public void destroyApp() { } }
Dont pay attention to the code here. I had explained about it in detail. Just note that this code will make an interface like this :
The textBox will be used as an output displaying screen.
Now if you have seen a simple hello word program in java , its code will look like this :
public class MyClass
{ public static void main(String[] args) { System.out.println("Hello world"); }
}
Now check what these things are , and compare it with the code we have written above :
1) MyClass in the name of class in desktop java -> MyMIDlet is the name of our class in j2me
2) The execution of program starts from the method main(String[] args) in desktop java -> The execution of program starts from startApp() in j2me.
3) To display "Hello world" in console (which work as output screen) in desktop java we write :
System.out.println("Hello world");
To display "Hello world" in textbox (which we are using as output screen) in j2me , we write :
mybox.setString("Hello world");
So simply saying ,
startApp() works as main(String[] args) in j2me
mybox.setString( ) works as System.out.println( ) in j2me |
5.88 KB, Downloads: 130
|
No comments:
Post a Comment