View Single Post
Old 05-27-2010, 01:02 AM   #1
Emmett
New Member
 
Join Date: Feb 2009
Model: 9700
PIN: N/A
Carrier: SFR
Posts: 3
Default MIDlet button working differently on a BlackBerry 9700 than on the SUN WTK simulator

Please Login to Remove!

Hi,

I am trying to design a 2 button interface using MIDlet 2.0 and CLDC 1.1 but get a different behaviour on the WTK simulator and on a BlackBerry 9700.
On the WTK simulator, the command behind the button is fired as soon as the button is pressed through the trackpad.
On a BlackBerry 9700, the first click on the button through the trackpad brings up the screen command menu and a second click on the command listed in this menu and linked to the button is necessary.
How can I make the BlackBerry 9700 work as with the WTK simulator, i.e. fire the command as soon as the button is pressed through the trackpad?
I wish to stay on the JME model and not going to the RIM SDK.

Thanks

package UI;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.ItemCommandListener;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeExcepti on;

public class MyButton extends MIDlet implements ItemCommandListener {
Display display;
Form form;
Command okCommand, exitCommand;
protected void startApp() throws MIDletStateChangeException {
display = Display.getDisplay(this);

form=new Form("2 button interface");

StringItem okButton=new StringItem(null, "Ok", Item.BUTTON);
okButton.setItemCommandListener(this);
okCommand=new Command("Ok",Command.ITEM, 0);
okButton.setDefaultCommand(okCommand);
okButton.addCommand(okCommand);
form.append(okButton);

StringItem exitButton=new StringItem(null, "Exit", Item.BUTTON);
exitButton.setItemCommandListener(this);
exitCommand=new Command("Exit",Command.ITEM, 0);
exitButton.setDefaultCommand(exitCommand);
exitButton.addCommand(exitCommand);
form.append(exitButton);

display.setCurrent(form);
}

public void commandAction(Command cmd, Item item) {
Alert alert=new Alert("Button pressed "+cmd.getLabel()+" "+item.toString());
display.setCurrent(alert);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
this.notifyDestroyed();
}

protected void pauseApp() {
}

}
Offline   Reply With Quote