By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,490 Members | 1,398 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,490 IT Pros & Developers. It's quick & easy.

J2ME question:how i can catch command event

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.