Is it possible to place buttons on a Form?

Is it possible to place buttons on a Form? I tried to place images to act as buttons, but some cell phones do not allow an image to gain focus. What is the way out?Thanks.
[185 byte] By [Talal_Itania] at [2007-11-26 19:44:20]
# 1
you can create your own CustomItem and put the image inside...
suparenoa at 2007-7-9 22:28:24 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
Yes you can without a customItem, check the wtk GUIs examples. There will find how to do it.
MelGohana at 2007-7-9 22:28:25 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

I'd like to give you a example for your request.

import javax.microedition.lcdui.*;

import javax.microedition.midlet.MIDlet;

public final class TestStringItemMIDlet extends MIDlet implements CommandListener, ItemCommandListener {

/** Soft button for exiting the demo. */

Form main_form = new Form("TestStringItem");

private Command exitCommand = new Command("Exit", Command.EXIT, 1);

private Command itemCommand = new Command("Item Command", Command.ITEM, 1);

StringItem normalItem = new StringItem("Plain:","World",Item.PLAIN);

StringItem commandItem = new StringItem("Button:","World",Item.BUTTON);

public void startApp() {

main_form.append(normalItem);

main_form.append(commandItem);

main_form.addCommand(exitCommand);

main_form.setCommandListener (this);

Display.getDisplay(this).setCurrent(main_form);

commandItem.setDefaultCommand(itemCommand);// add Command to Item.

commandItem.setItemCommandListener(this);// set item command listener

}

public void pauseApp() {

}

public void destroyApp(boolean unconditional) {

}

public void commandAction(Command c, Displayable s) {

if (c == exitCommand) {

destroyApp(true);

notifyDestroyed();

}

}

public void commandAction(Command c, Item item)

{

if(c == itemCommand)

{

normalItem.setText("OK! Item command clicked!");

}

}

}

yixiaoqianga at 2007-7-9 22:28:25 > top of Java-index,Java Mobility Forums,Java ME Technologies...