Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 41
Registered: ‎11-15-2012
My Device: Curve 9320
My Carrier: Optimus


I'm create a class ComboBox but I can not find a method to the press a list item it shows a message with the item for the item clicked.

My applicaton is:


I'm create combobox with values


String[] array = {"value 1","value 2","value 3"};
cb = new ComboBox(array,200);



The class ComboBox is:


public class ComboBox extends ObjectChoiceField {
private final int PADDING_HEIGHT = 20;
private final int width;
private final int height;

public ComboBox(Object[] choices, int width) {
super("", choices, 0, FIELD_LEFT);
this.width = width;
this.height = getFont().getHeight() + PADDING_HEIGHT;

public int getPreferredHeight() {
return height;

public int getPreferredWidth() {
return width;

protected void layout(int w, int h) {
setExtent(width, height);

public void getFocusRect(XYRect rect) {
rect.set(getFont().getAdvance(getLabel()), 0, width, height);





Posts: 41
Registered: ‎11-15-2012
My Device: Curve 9320
My Carrier: Optimus

Re: ComboBox

It's work! The code for solution is:


cb.setChangeListener(new FieldChangeListener() {

public void fieldChanged(Field field, int context) {
if ( field instanceof ObjectChoiceField ) {
ObjectChoiceField test= (ObjectChoiceField)field;
Dialog.alert("choice" + test.getSelectedIndex() + "has been pressed");