471,069 Members | 1,361 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,069 software developers and data experts.

J2ME question:how i can catch command event

Hi, all!

I am new with J2ME.

I have application that has form with 2 commands (exit and select).
All UI uses are high level API, and it is very important to leave it
high-level.
This application works fine on some devices. But at Samsung mobile
phone, I have a problem.
In this phone my 2 commands appear under menu command, and then I can
choose one of them. New command "OK" is added only on phone.

My question is:
1. How I can catch event on this OK command?
2. Is there any way to use keyPressed method of Canvas class in Form
class?
3. Any suggestions are welcome.
Jul 17 '05 #1
1 3876
Sveta wrote:
I am new with J2ME.
You're most likely referring to the MID Profile. J2ME is not a particular
technology or environment, but refers to all technologies on handheld and
embedded devices. [/nitpick] ;)
I have application that has form with 2 commands (exit and select).
All UI uses are high level API, and it is very important to leave it
high-level.
This application works fine on some devices. But at Samsung mobile
phone, I have a problem.
In this phone my 2 commands appear under menu command, and then I can
choose one of them. New command "OK" is added only on phone.
That's standard for SprintPCS phones. Even if you don't respond to the
command, it's there.
My question is:
1. How I can catch event on this OK command?
In your commandAction(Command,Displayable) for the CommandListener for that
screen, you would use the following code pattern:

public void commandAction(Command c,Displayable d)
{
switch(c.getCommandType())
{
case Command.OK: // this is the OK command
// do your stuff
}
}
2. Is there any way to use keyPressed method of Canvas class in Form
class?
No. Those methods are part of the low-level UI APIs. If you look at the
class hierarchy, you'll see that Canvas is not the base for the high level
widgets, even though the *implementation* may make them so.
3. Any suggestions are welcome.


See the J2ME FAQ: <http://mcpierce.mypage.org/j2mefaq.html>

--
Darryl L. Pierce <mc******@myrealbox.com>
Visit the Infobahn Offramp - <http://mypage.org/mcpierce>
"What do you care what other people think, Mr. Feynman?"
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by msnews.microsoft.com | last post: by
1 post views Thread by Steve Kershaw | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.