J2ME question:how i can catch command event

S

Sveta

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.
 
D

Darryl L. Pierce,,,

Sveta said:
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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top