J2ME: TextField.setDefaultCommand() problem!

S

Simon Brooke

Somebody please give me a clue to where I'm going wrong here!

I've got a barcode scanner which generates the characters of the barcode,
followed by return. It goes into a TextField in a MIDlet form. The MIDlet
implements Command Listener

public class FieldKitMidlet extends MIDlet implements CommandListener

The TextField is just a TextField:

protected TextField inputLine =
new TextField( getConfig( "FieldKitMidlet-InputLabel" ), null,
AbstractFieldKit.MAXINPUT, TextField.ANY );

It has a default command set on it, as follows:

Command enter =
new Command( getConfig( "FieldKitMidlet-EnterLabel" ),
Command.OK, 0 );
inputLine.addCommand( enter);
inputLine.setDefaultCommand( enter );
form.append( inputLine );

In an earlier version of the software, when you clicked the scan button,
the barcode value immediately appeared in the input line, and the command
associated with Command.OK happened automatically. The barcode scanner
software hasn't changed. The commandAction(Command,Displayable) method
hasn't changed.

So what, exactly, are the conditions in which a return character should or
should not trigger the default action on a TextField? What can I do to
make this work again?
 

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,777
Messages
2,569,604
Members
45,228
Latest member
MikeMichal

Latest Threads

Top