aspose file tools*
The moose likes Java Micro Edition and the fly likes My first mobile application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "My first mobile application" Watch "My first mobile application" New topic
Author

My first mobile application

Ali Kiyani
Greenhorn

Joined: Sep 15, 2005
Posts: 7
Today is my first day in MIDP.

I am trying to make a calculator that will add two numbers and then will display the result.

I have added a Form and on that form there are two TextFields. There are also two buttons OK and CANCEL.

What I want is when the user presses the OK button then it should call the function AddNumber() but I don't know how to do that because when I presses it, it goes back to the previous screen like CANCEL button. How can I do that?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Well, when you created your Button you made it of type OK, which defaults to closing the Form. What you want is the type that is SCREEN.

Taken from the Javadocs


static int OK
A command that is a standard positive answer to a dialog implemented by current screen.
static int SCREEN
Specifies an application-defined command that pertains to the current screen.


Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ali Kiyani
Greenhorn

Joined: Sep 15, 2005
Posts: 7
Thanks it works!

One more thing. When I ran the program it created a .jad file and one MANIFEST file. I transferred them in my friend's Samsung mobile (it supports java but don't know which version) but it didn't work there! Is there anything else that I need to do to install the program on mobile!?
How do I know on which mobile my program will work!?

Take a look at source code which may give you some idea.


[ September 16, 2005: Message edited by: Ali Kiyani ]
Ali Kiyani
Greenhorn

Joined: Sep 15, 2005
Posts: 7
Ok I managed to run it on mobile. The solution is, create a JAR file of your project and install it rather than installing JAD file on mobile.

But my other questions still remains the same and that is:

How do I know that my application will work on certain models? As you can see I have not defined anything in the code so I guess it picks up the default settings. What are those default settings and how can I define my own that this application will target some specific models?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Well, that's the trick. J2ME CLDC, MIDP are just specification for the device manufacturer to implement if it wants to call the phone a J2ME enabled phone for whatever version if MIDP CLDC. Some devices has proprietary APIs that you can add on top of J2ME, but then your code is locked to that device.

If you want to create specific jars for specific devices based on features that one phone implements that another does not. You either have to have spereate projects for each type of device and have special code in each for that particular device.

Or you can make it "easier" on yourself by using J2ME Polish. Now "easier" in that you will have only one baseline of code, but you would still have to learn J2ME Polish to use it to its fullest potential.

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My first mobile application
 
Similar Threads
Avoiding validation when hitting the Cancel button
problem using validator framework with DispatchAction
Cancel button and bypassing JavaScript validation
cancel button issue
prompt