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

BlackBerry® World™ Development

New Contributor
Posts: 5
Registered: ‎05-16-2011
My Device: 8900
My Carrier: Digicel

Bb hello world code


I just went thru the helloworld app yesterday. Today I went thru A11 UserInterface code and ran it on eclipse on my 8900 simulator but the buttons don't show up. Here's my code:

package UserInterfacePackage;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

* A class extending the MainScreen class, which provides default standard
* behavior for BlackBerry GUI applications.
public final class MyScreen extends MainScreen
   HorizontalFieldManager _fieldManagerTop;
   VerticalFieldManager _fieldManagerMiddle;
   HorizontalFieldManager _fieldManagerBottom;
   BitmapField _bitmap;
   Bitmap _canadaImage, _ukImage, _usImage;
   LabelField _label;
   BasicEditField _input;
   String _canadaCapital, _ukCapital, _usCapital, _capital;
   int displayed = 0;
    * Creates a new MyScreen object
   public MyScreen()
       // Set the displayed title of the screen       
       LabelField title = new LabelField("User Interface
Sample",LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);

       //HorizontalFieldManager _fieldManagerTop;
       //VerticalFieldManager _fieldManagerMiddle;
       //HorizontalFieldManager _fieldManagerBottom;

       _fieldManagerTop = new HorizontalFieldManager();
       _fieldManagerMiddle = new VerticalFieldManager();
       _fieldManagerBottom = new HorizontalFieldManager();
       add(new SeparatorField());
       add(new SeparatorField());

       //BitmapField _bitmap;
       //Bitmap _canadaImage, _ukImage, _usImage;

       _canadaImage = Bitmap.getBitmapResource("canada.png");
       _ukImage = Bitmap.getBitmapResource("uk.png");
       _usImage = Bitmap.getBitmapResource("us.png");
       _bitmap = new BitmapField();

       // Capitals
       //LabelField _label;
       //BasicEditField _input;
       //String _canadaCapital, _ukCapital, _usCapital, _capital;
       _canadaCapital = "Ottawa";
       _ukCapital = "London";
       _usCapital = "Washington";
       _capital = _canadaCapital;
       _label = new LabelField("Please press a button!");
       _input = new BasicEditField("Capital (can be changed):", _capital);

       ButtonField canadaButton = new ButtonField("Canada");
       ButtonField ukButton = new ButtonField("  UK  ");
       ButtonField usButton = new ButtonField("  US  ");

       //add listeners to buttons
       FieldChangeListener listenerCanada = new FieldChangeListener(){
       public void fieldChanged(Field field, int context) {
       displayed = 0;

       FieldChangeListener listenerUK = new FieldChangeListener(){
       public void fieldChanged(Field field, int context) {
       displayed = 1;

       FieldChangeListener listenerUS = new FieldChangeListener(){
       public void fieldChanged(Field field, int context) {
       displayed = 2;

       // assign listeners to buttons

       // add buttons to the managers

       protected void makeMenu(Menu menu, int instance) {

       private MenuItem _changeCapital = new MenuItem("Change Capital", 110,
       public void run(){
       if (displayed == 0)
       _canadaCapital = _input.getText();
       else if (displayed == 1)
       _ukCapital = _input.getText();
       else if (displayed == 2)
       _usCapital = _input.getText();

       private MenuItem _close = new MenuItem("Close", 110, 10) {
       public void run(){

       public boolean onClose() {
       return true;

Anything strikes anyone as outta whack?