ObjectChoiceField FieldChangeListener problem

Hi all

I'm coding an application for 4.5 but testing on BB 9500.

I want to a few call webservice on the choice of an ObjectChoiceField.

But the problem is that the FieldChangeListener of the ObjectChoiceField fires on the development as well as on the selection of the field.

How to distinguish two event?

Thaks for your help in advance.

Hi all

I found the solution to my problem.

Below is sample code for the solution.

ObjectChoiceField myObjectField= new ObjectChoiceField("",new String[] { "" }, 0, FIELD_LEFT)
{
    protected void fieldChangeNotify(int context)
    {
    new myObjectField_change_method();
    }
    public void focusChangeNotify(int arg0)
    {
    super.focusChangeNotify(arg0);
    }
};

In the code above myObjectField_change_method() is a method to be triggered when the field is selected.

Tags: BlackBerry Developers

Similar Questions

  • BitmapField FieldChangeListener problem

    Hello

    I use BitmapField as a button with the two FieldChangeListener and

    FocusChangeListener in my application.

    In FocusChangeListener I change just image of bitmapfield

    and in FieldChangeListener, I gave a single action.

    Problem is when BitmapField won the development, called FieldChangeListener

    What could be the solution to prevent this?

    I want action to call only to click and not on the FOCUS_GAINED event

    Hello

    Instead of domain change listener tries with method "click browsing..."

    ----------------------------------------------------------------------------------------------------------------------------------------------------------

    Press 'Congratulations' if it helps

  • ObjectChoiceField layout problem

    Hi friends,

    I'm putting an ObjectChoiceField on the 8900 4.6.1 OS version and the rect of the field is not shown.

    5.0 Os version works quite well.

    below the picture on 4.6.1...  The two fields are editable ObjectChoiceFields.

    Note: the functtionality is correct only visual is not good in 4.6.1.

    Thank you all.

    It is a behavior of OS version, I realized. The solution was to implement a custom choicefield.

  • problem with my screen and ObjectChoiceField, help!

    Hi, I have a screen where there are two objectChoiceField. I want to make is that, according to the value that we chose in the first objectChoiceField, the second objectChoiceField also selectable values change. I tried in the trackwheelclick, change the first objectChoiceField, repaint the screen with the choice in this election and that option objectChoiceField the second change, but I don't not do, what am I doing wrong? Thanks in advance and sorry for my English, this is my code:

    public class MovimientoInvScreen extends MainScreen{
    
        private InformesController controller;
    
        private HorizontalFieldManager containerHoriz;
    
        private RoundRectContainer containerDatosEco;
        private RoundRectContainer containerDatosRRHH;
        private RoundRectContainer containerInfoAmpli;
    
        private GridFieldManager containerGridEco;
        private GridFieldManager containerGridRRHH;
        private GridFieldManager containerGridInfoAmpli;
    
        private ButtonField buttonMover;
    
        private BasicEditField codigo;
        private ObjectChoiceField boxProv;
        private ObjectChoiceField boxCentro;
    
        private CentroDTO centro;
        private KeyValue provincia;
        private Vector centros;
        private KeyValue provinciaActual;
    
        public MovimientoInvScreen(InformesController controller) throws Exception{
    
            this.controller = controller;
            controller.obtenerDetallesCentro();
    
            centro = controller.getCentroSeleccionado();
    
            provincia = controller.getProvinciaSeleccionada();
    
            setTitle("Mov. inventario " + centro.getNombre());
    
            containerHoriz = new HorizontalFieldManager();
    
            String choiceProv[] = {"Almería", "Cádiz", "Córdoba", "Granada", "Huelva", "Jaen", "Málaga", "Sevilla"};
            boxProv = new ObjectChoiceField ("Provincia",choiceProv, provincia.getDescripcion());
    
            centros = controller.obtenerCentrosProvincia(provincia.getId());
            Object choiceCentro[] = new Object [centros.size()];
    
            for (int i=0; i< centros.size(); i++){
                choiceCentro[i] = centros.elementAt(i);
            }
    
            boxCentro = new ObjectChoiceField ("Centro de destino", choiceCentro);
    
            codigo = new BasicEditField("Activo                                      ",
                    "", 10,    BasicEditField.FILTER_NUMERIC | Field.FOCUSABLE);
    
            buttonMover = new ButtonField("Mover", Field.FIELD_HCENTER);
    
            add(boxProv);
            add(boxCentro);
            add(codigo);
    //        add(buttonCamara);
            add(buttonMover);
        }
    
        protected void makeMenu(Menu menu, int instance) {
    
            super.makeMenu(menu, instance);
        }
    
        protected boolean trackwheelClick(int status, int time) {
    
            try{
    
                if(boxProv.isDirty()){
    
                    provinciaActual = ((KeyValue) boxProv.getChoice(boxProv.getSelectedIndex()));
                    if (provincia != provinciaActual){
    
                        boxProv.setDirty(false);
                        this.controller.setProvinciaSeleccionada(provinciaActual);
    
                        UiApplication.getUiApplication().popScreen(MovimientoInvScreen.this);
                        UiApplication.getUiApplication().pushScreen(new MovimientoInvScreen(this.controller));
                    }
    
            }catch(Exception e){
                Dialog.inform(e.getMessage());
            }
            return super.trackwheelClick(status, time);
        }
    
        public boolean onClose() {
            int i = Dialog.ask(Dialog.D_YES_NO, "¿Desea cerrar la aplicación?");
            if (i == Dialog.YES)
                System.exit(0);
    
            return true;
        }
    
        protected boolean keyChar(char key, int arg1, int arg2) {
            if(key == Characters.ESCAPE){
                UiApplication.getUiApplication().popScreen(MovimientoInvScreen.this);
                return true;
            }else
                return super.keyChar(key, arg1, arg2);
        }
    }
    

    I think that the example code provided by Dmitry is more complex that it must be to demonstrate this link.  I hope that the following code is easier to understand.

    import net.rim.device.api.i18n.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    
    public class ObjectChoiceFieldTestScreen extends MainScreen
                                             implements FieldChangeListener {
    
        static String [] COUNTRIES = new String [] { "England", "US", "Canade" };
        static String [] ENGLAND_CITIES = new String [] { "London", "Liverpool" };
        static String [] US_CITIES = new String [] { "New York", "Washington", "Boston", "San Francisco" };
        static String [] CANADA_CITIES = new String [] { "Montreal", "Toronto", "Vancouver" };
        ObjectChoiceField _countryChoice = new ObjectChoiceField("Select Country:", COUNTRIES);
        ObjectChoiceField _cityChoice = new ObjectChoiceField("Select City:", null);
    
        public ObjectChoiceFieldTestScreen() {
            super();
            this.setTitle("Test ObjectChoiceField Linking");
            this.add(_countryChoice);;
            _countryChoice.setSelectedIndex(1);
            fieldChanged(_countryChoice, 0); // This just simulates the first 'setting' of the choice
            _countryChoice.setChangeListener(this);
            this.add(_cityChoice);
    
        }
    
        public void fieldChanged(Field f, int context) {
            if ( f != _countryChoice ) {
                return;
            }
            int countryIndex = _countryChoice.getSelectedIndex();
            if ( countryIndex == 0 ) {
                _cityChoice.setChoices(ENGLAND_CITIES);
            } else
            if ( countryIndex == 1 ) {
                _cityChoice.setChoices(US_CITIES);
            } else {
                _cityChoice.setChoices(CANADA_CITIES);
            }
        }
    }
    

    This illustrates the connection but hides a problem.  Changing the initial index of 1 (US) to 0 (England) and see what happens to the width of the field of cities.  There is a way around that.  But let's get the first sorted sequence.

  • ObjectChoiceField and FieldChangeListener

    I'm creating an application (Storm 9530 component package 4.7) that uses an ObjectChoiceField which is filled by anywhere from 1 to 50 choice programming.  I would use the FieldChangeListener to generate a new pop-up screen based on the selection made by the user of the ObjectChoiceField.  Because the list can be quite long, the user may need to scroll the list to find their choice.  Each time the selection is changed in the FieldChangedListener is called, but I want only to take action in the final selection is made ("clicked").  I have been in charge of the search and search but have not found the key to understand the current state of the ObjectChoiceField (open or closed).  Any help would be greatly appreciated.

    TIA,

    Tim

    You will not be able to differentiate between these types of changes within a FieldChangeListener.  Instead, you might have the user selects an entry and use a ButtonField or MenuItem to check their choice.  Or you could have your action occur when the focus is moved out of the ObjectChoiceField.

  • Strange: Objectchoicefield and ObjectListField in Gridfieldmanager - navigation problem

    Hi @all,

    I have a very strange problem, because running Simulator runs as I would have liked, but the device, the navigation is bad:

    running OS 5.0.0.42 3 on device (BB9700) and the Simulator

    1. the building screen

    2. put verticalfieldmanager on it that contains the background image

    3. put gridscreenmanager (with a column - the problem is with more then one column, too) on the first position of the vfm

    4. turn objectchoicefield with 5 points on the 1st row of the gsm

    5. put the objectlistfield with 5 points on the second line of gsm

    Program running in the Simulator:

    View all as I prefer.

    The first objectchoicefield and beyond the objectlistfield.

    When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.

    I can scroll up and down, and everything's fine.

    Program running on the device:

    View all as I prefer.

    The first objectchoicefield and beyond the objectlistfield.

    When I scroll with trackpad OCF Gets the focus first and after that the olf on its first line.

    So far so good:

    When I scroll down to the olf, all things are working properly. For example, point 4 a now focus.

    Now, if I try to go back in the OLF, it should go back to article 3 of the olf, but this is the leap into objectchoicefield. After that, if I try to go back to the objectlistfield, it jumps directly to point 4, which he came before.

    If I don't put the objectchoicefield in the first row, everything works fine.

    What can I do?

    I did something wrong?

    All ideas are very appeciated.

    Thanks in advance.

    CUA

    Michael

    Well, I found it.

    I made a mistake in the application of my own gridfieldmanager navigationmovement method.

    What is already strange: I used the same gridfieldmanager within 2 screens in my application. First screen was working fine, the second one was bad. Same content in both screens.

    Sorry for that.

    Thank you for all.

    CUA

    Michael

  • First choice in ObjectChoiceField do not call FieldChangeListener.

    Hello everyone, I have a choice of object field to display a list of the cities. I gave the initial value for field as the first city in the list of cities. I put the changes for the field and hadling the event listener using fieldChanged().

    I use getSelectedIndex() to treat the choice more far. When I choose choice other than the first (0th position choice), it works fine. But when I choose the first, nothing happens. I debugged n saw that control comes not at all to the fieldChanged() method.

    My code is as below:

    mCityDropDown.setChangeListener (new FieldChangeListener() {}
                
    ' Public Sub fieldChanged (field field, int context) {}
                    
    if(Context == 0) {}
    return;
    }
    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
                            
    public void run() {}
    Dialog.Inform ("Index:" + mCityDropDown.getSelectedIndex ());

    }
    });

    }

    });

    Can anyone tell if I am wrong somewhere n suggest me the solution. Thanks in advance.

    The default value of the change listener, it fires if something is changed.
    as the index is 0 before AND after there is no change.
    You must adapt your application logic to that.

  • ObjectChoiceField problem

    Hello

    When I designed the user interface, I used the ObjectChoiceField. The code is as follows:

    String choice [] = new String [7];
           
    choice [0] = "Mon";
    choice [1] = "Tuesday";
    choice [2] = 'Sea.';
    choice [3] = "SAT.";
    choices [4] = "Friday";
    choice [5] = "Sat.";
    choice [6] = "Sun";
           
    cfDay = new ObjectChoiceField ("day:", choice, 0);

    But I think the legend 'Day' is very far from the era, like MON or Tues...

    That's why a big void between the legend and the actual data.

    How to remove the cache between them?

    Thank you

    Jerry

    cfDay = new ObjectChoiceField ("day:", choice, 0, ObjectChoiceField.FIELD_LEFT);

  • Problem with ObjectChoiceField

    Hi friends,

    I created a choice of object field and I try to load the values into this field of choice of object during execution. What I did, I used (setchoice) method to set a value to a time of execution. I can get the values of what I put in execution but the problem I m facing is, if we go after the last element in the choice of subject field it will be thanks to a special null pointer and his watch is not the first element of the array. Can U help pls how to overcome this problem and pls tell no matter what happens, the reason for this problem...

    Kind regards

    s.Kumaran.

    Ooops... It was a mistake to programming baisc. glad you figured it out. You can mark the thread as solved.

  • ObjectChoiceField.setChoice () - screen problem


    Solved.  Had with the field is not unable to "gracefully" to handle a null value in the [(see loop for).

  • How to remove a Custom DDL or ObjectChoiceField

    Hi all

    I am doing a shopping basket sort of thing...! for this I need to change the dropdownlists dynamically on the selection.

    !) When the user selects the button category, main ddl should be updated.

    (2) when the user selects a subacaegory of DOF, DOF sub must be courses.

    I realized this some how... dynamically, I changed the reference to the ddl and updated. It works fine but the problem is, when an another DOF makes its appearance the previous is there remain only and a new is overwhelming at this point. as a result when the width of the new ddl is lower than the previous ddl, it appeared in her underwear, which kills the look and feel of the screen.

    in some ways, I tried to remove the ddl, but it does not work for me.

    Please suggest me how to remove the ddl dynamically, when I try to remove it, it gives IllegalArgumentException meaning is the ddl

    not this Manager field. I'm removing the same administrator only, but I have not found why it's happening...!

    Please help me! Here is my

    It's my custom ddl code.

    public class CustomComboBox extends ObjectChoiceField   {
    
          private int width;        public boolean itemadded = false;
    
    //       CustomComboBox()//        {////         super("Currency",curr, 0, ObjectChoiceField.FIELD_LEFT);//        }     public CustomComboBox(String str,String []curr, int width)        {         super(str, curr, 0, ObjectChoiceField.FIELD_LEFT | ObjectChoiceField.USE_ALL_WIDTH);          this.width = width;           Font font = this.getFont().derive(Font.EMBOSSED_EFFECT | Font.BOLD, 14);          this.setFont(font);
    
         }     public CustomComboBox(String str,String []curr, int startindex, int width)        {         super(str, curr, startindex, ObjectChoiceField.FIELD_LEFT | ObjectChoiceField.USE_ALL_WIDTH);         this.width = width;           Font font = this.getFont().derive(Font.EMBOSSED_EFFECT | Font.BOLD, 14);          this.setFont(font);       }     protected void layout(int width, int height)      {         setExtent(this.width, 40);        }     public void paint(Graphics g)     {           //            g.setBackgroundColor(Color.BLUE);//           g.clear();            g.setColor(Color.BLACK);          super.paint(g);       }     public void setVisiblity(boolean on)      {//           this.setVisualState(VISUAL_STATE_DISABLED);//         this.setVisualState(VISUAL_STATE_DISABLED_FOCUS);
    
          }     protected void fieldChangeNotify(int context)        {          try {              this.getChangeListener().fieldChanged(this, context);                 } catch (Exception exception) {               }        } }
    

    This is the place where to use this object class

    class ItemList extends Manager implements FieldChangeListener{  SubItemList subitems;
    
      String []cycleitems = {"Standard", "Kids", "Racers"}; String []spareitems = {"Tyres", "Tubes", "Covers"};   String []healthitems = {"Medicines","Fruits","Drinks"};   String []fitnessitems = {"Walker", "Dumbles"};    String []empty = {"                    "};
    
      CustomComboBox ddl_cycle, ddl_spares, ddl_fitness, ddl_health, ddl;   MyTextField lbl_subcategory;//    CustomTextBox txt_qty;    ItemList(int index)   {     super(Manager.VERTICAL_SCROLL | Manager.HORIZONTAL_SCROLL);
    
            subitems = new SubItemList(index,0);
    
          ddl_cycle = new CustomComboBox("Cycles", cycleitems,  140);       ddl_spares = new CustomComboBox("Spares", spareitems, 140);       ddl_health = new CustomComboBox("Health", healthitems, 140);      ddl_fitness = new CustomComboBox("Fitness", fitnessitems,140);        ddl = new CustomComboBox("",empty ,100);
    
          lbl_subcategory = new MyTextField("Sub-Category:",Field.FIELD_LEFT, 16);//        lbl_qty = new MyTextField("Qty", Field.FIELD_LEFT, 16);//     txt_qty = new CustomTextBox(30,20);
    
          ddl_cycle.setChangeListener(this);        ddl_spares.setChangeListener(this);       ddl_health.setChangeListener(this);       ddl_fitness.setChangeListener(this);
    
          switch(index)     {         case 0: ddl = ddl_cycle;                  break;            case 1: ddl = ddl_spares;                 break;            case 2: ddl = ddl_health;                 break;            case 3: ddl = ddl_fitness;                    break;        }     add(lbl_subcategory);     add(ddl);     add(subitems);    } public void delItems()    {     subitems.delSubItems();       deleteAll();  } public void setvisibility(boolean on) {     ddl.setVisiblity(false);  } protected void sublayout(int width, int height)   {     if(lbl_subcategory != null)       {         setPositionChild(lbl_subcategory, 0, 25);         layoutChild(lbl_subcategory, getScreen().getWidth(), getScreen().getHeight());        }
    
          setPositionChild(ddl, 110, 15);       layoutChild(ddl, getScreen().getWidth(), getScreen().getHeight());
    
          if(subitems != null)      {         setPositionChild(subitems, 0, 60);            layoutChild(subitems, getScreen().getWidth(), getScreen().getHeight());       }
    
          setExtent(360, 150);  }
    

    This is the place where works the dynamic change of ddl

    class OrderEntryManager extends Manager implements FieldChangeListener{
    
    ItemList items;    ButtonField   btn_submit;     MyButtonField  btn_cycles, btn_spares, btn_health, btn_fitness, btn_go;
    
    OrderEntryManager(){items = new ItemList(0);btn_cycles = new MyButtonField("Cycles", "orderimg/cycle.png", "orderimg/cycle.png",0x00FFE7AD);     btn_spares = new MyButtonField("Spares", "orderimg/spares.png", "orderimg/spares.png",0x00FFE7AD);        btn_fitness = new MyButtonField("Fitness", "orderimg/fi.....);
    
    add(items);
    
    }public void fieldChanged(Field field, int context)    {
    
          if(field instanceof MyButtonField)        {         if (((MyButtonField) field).getLabel().equalsIgnoreCase("Cycles"))            {//               items.delItems();//               this.delete(items);//             items.setVisualState(VISUAL_STATE_DISABLED);              items.setvisibility(false);               items = new ItemList(0);              add(items);            }            else if (((MyButtonField) field).getLabel().equalsIgnoreCase("Spares"))           {//               items.setVisualState(VISUAL_STATE_DISABLED);//                items.setvisibility(false);               items = new ItemList(1);              add(items);//             items = itemsnew;         }         else if (((MyButtonField) field).getLabel().equalsIgnoreCase("Health"))           {//               items.setVisualState(VISUAL_STATE_DISABLED);//                items.setvisibility(false);               items = new ItemList(2);              add(items);//             items = itemsnew;         }         else if(((MyButtonField) field).getLabel().equalsIgnoreCase("Go"))            {
    
              }         else if (((MyButtonField) field).getLabel().equalsIgnoreCase("Fitness"))          {//               items.setVisualState(VISUAL_STATE_DISABLED);//                items.setvisibility(false);               items = new ItemList(3);              add(items);//              items = itemsnew;            }     }     else if (field instanceof ButtonField)         {//           if (((ButtonField) field).getLabel().equalsIgnoreCase("Fitness"))//              {//                   items = new ItemList(3);//                    add(items);// //               items = itemsnew;  //                }           if(((ButtonField) field).getLabel().equalsIgnoreCase("Submit"))             {               synchronized(Application.getEventLock())                    {                     UiApplication.getUiApplication().popScreen(UiApplication.getUiApplication().getActiveScreen());                       UiApplication.getUiApplication().pushScreen(new OrderConfirmScreen());                    }             }      }            if(items != null)         {             updateLayout();           }
    
     }
    
    }
    

    Please suggest me how to remove the ddl for this!

    Hi all, I have solved this problem by using ddl.setChoice (String []);

    Thank you for all that you.

  • using the App: variable scrollbar help and problems

    It is a large amount of code, but please bare with me please.  I would really appreciate the help!

    If I write a financial application where the user enters the initial investment, the compound interest rate period and duration of investment and it calculates the value.  Here is my code: each "screen" that appears on the emulator is its own class:

    package com.rim.samples.Finance;
    
    import net.rim.device.api.ui.UiApplication;
    
    public class FinanceApplication extends UiApplication
    {
        //VARIABLES FOR THE INVESTMENT GROWTH
        public double initialInvestment;
        public double interest;
        public int compoundPeriod;
        public int investmentLength;
    
        public static void main(String[] args)
        {
            FinanceApplication firstApplication  = new FinanceApplication();
            firstApplication.enterEventDispatcher();
        }
    
        public FinanceApplication()
        {
            //OPENING SCREEN FOR INVESTMENT GROWTH
            pushScreen(new Screen1());
        }
    
    }
    
    //SCREEN 1 INPUTS *INITIAL INVESTMENT*
    
    package com.rim.samples.Finance;
    
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.Manager;
    import net.rim.device.api.ui.MenuItem;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.BasicEditField;
    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;
    import net.rim.device.api.ui.decor.Border;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public class Screen1 extends MainScreen implements FieldChangeListener
    {
    
        //DECLARE MENU BUTTONS
        protected void makeMenu(Menu menu, int instance)
        {
    
            menu.add(_close);
        }
        private MenuItem _close = new MenuItem("Close", 110, 10)
        {
            public void run()
            {
                onClose();
            }
        };
        public boolean onClose()
        {
            Dialog.alert("Goodbye!");
            System.exit(0);
            return true;
        }
    
        //SCREEN 1 METHOD
        Screen1()
        {
    
            HorizontalFieldManager _fieldManagerTop = new HorizontalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
            VerticalFieldManager _fieldManagerMiddle = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
            HorizontalFieldManager _fieldManagerBottom = new HorizontalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
            HorizontalFieldManager _fieldManagerButton = new HorizontalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    
            //SET TITLE: FINANCIAL APPLICATION
            LabelField title = new LabelField ("Financial Application", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            Font titleFont = this.getFont().derive(Font.BOLD | Font.ITALIC);
            title.setFont(titleFont);
            setTitle(title);
    
            //SET PAGE & INFO TEXT
            LabelField _page = new LabelField("Homepage ~ Initial Investment", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            LabelField _info = new LabelField("\nThis application acts as a an investment or growth calculator.  The user inputs the amount of money he or she would like to invest originally, input the interest, the compound period, the regular monthly deposit into the investment, and the time her or she will have the investment and this application will calculate how much the investment will be worth.\n\n Please enter initial amount of money you are depositing into the investment.\n$XX.xx", LabelField.USE_ALL_WIDTH);
    
            //INPUT FIELDS TESTING!!!!
    
            //INPUT FIELD W/ BORDER
            BasicEditField _input = new BasicEditField();
    
            XYEdges padding = new XYEdges(10, 10, 10, 10);
            int color = Color.DARKGREEN;
            int lineStyle = Border.STYLE_SOLID;
            Border inputBorder = BorderFactory.createRoundedBorder(padding, color, lineStyle);
            _input.setBorder(inputBorder);
    
            //ADD FIELDS AND SEPARATORS
            add(_fieldManagerTop);
            add(new SeparatorField());
            add(_fieldManagerMiddle);
            add(new SeparatorField());
            add(_fieldManagerBottom);
            add(new SeparatorField());
            add(_fieldManagerButton);
    
            //ADD PAGE, INFO, INPUT
            _fieldManagerTop.add(_page);
            _fieldManagerMiddle.add(_info);
            _fieldManagerBottom.add(_input);
    
            //CREATE BUTTON TO NEXT PAGE
            ButtonField pressButton = new ButtonField("NEXT");
            pressButton.setChangeListener(this);
            _fieldManagerButton.add(pressButton);
    
        }
    
        //BUTTON FIELD CHANGE: ACTIONS
        public void fieldChanged(Field field, int context)
        {
            // PROBLEM IS HERE, I WANT WHATEVER IS TYPED INTO _input TO BE SET AS THE VARIABLE initialInvestmentFinanceApplication.initialInvestment=_input;
    
            UiApplication.getUiApplication().popScreen(this);
            UiApplication.getUiApplication().pushScreen(new Screen2());
    
        }
    
    }
    
    //SCREEN 2 INPUTS *INTEREST*
    
    package com.rim.samples.Finance;
    
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.MenuItem;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.BasicEditField;
    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;
    import net.rim.device.api.ui.decor.Border;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public class Screen2 extends MainScreen implements FieldChangeListener
    {
        //DECLARE MENU BUTTONS
        protected void makeMenu(Menu menu, int instance)
        {
            menu.add(_home);
            menu.add(_close);
        }
    
        private MenuItem _home = new MenuItem("Home Page", 110, 10)
        {
                public void run()
                {
                    onHome();
                }
        };
    
        public boolean onHome()
        {
            Dialog.alert("Homepage Selected");
            UiApplication.getUiApplication().popScreen(this);
            UiApplication.getUiApplication().pushScreen(new Screen1());
            return true;
        }
    
        private MenuItem _close = new MenuItem("Close", 110, 10)
        {
            public void run()
            {
                onClose();
            }
        };
    
        public boolean onClose()
        {
            Dialog.alert("Goodbye!");
            System.exit(0);
            return true;
        }
    
        //SCREEN 2 METHOD
        Screen2()
        {
            HorizontalFieldManager _fieldManagerTop = new HorizontalFieldManager();
            VerticalFieldManager _fieldManagerMiddle = new VerticalFieldManager();
            HorizontalFieldManager _fieldManagerBottom = new HorizontalFieldManager();
            HorizontalFieldManager _fieldManagerButton = new HorizontalFieldManager();
    
            //SET TITLE: FINANCIAL APPLICATION
            LabelField title = new LabelField ("Financial Application", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            Font titleFont = this.getFont().derive(Font.BOLD | Font.ITALIC);
            title.setFont(titleFont);
            setTitle(title);
    
            //SET PAGE & INFO TEXT
            LabelField _page = new LabelField("Page Two ~ Interest", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            LabelField _info = new LabelField("\nNow please enter the interest that will be put on this investment", LabelField.USE_ALL_WIDTH);
    
            //INPUT FIELD W/ BORDER
            BasicEditField _input = new BasicEditField();
            XYEdges padding = new XYEdges(10, 10, 10, 10);
            int color = Color.DARKGREEN;
            int lineStyle = Border.STYLE_SOLID;
            Border inputBorder = BorderFactory.createRoundedBorder(padding, color, lineStyle);
            _input.setBorder(inputBorder);
    
            //ADD FIELDS AND SEPARATORS
            add(_fieldManagerTop);
            add(new SeparatorField());
            add(_fieldManagerMiddle);
            add(new SeparatorField());
            add(_fieldManagerBottom);
            add(new SeparatorField());
            add(_fieldManagerButton);
    
            //ADD PAGE, INFO, INPUT
            _fieldManagerTop.add(_page);
            _fieldManagerMiddle.add(_info);
            _fieldManagerBottom.add(_input);
    
            //CREATE BUTTON TO NEXT PAGE
            ButtonField pressButton = new ButtonField("NEXT");
            pressButton.setChangeListener(this);
            _fieldManagerButton.add(pressButton);
    
        }
    
        //BUTTON FIELD CHANGE: ACTIONS
        public void fieldChanged(Field field, int context)
        {
            UiApplication.getUiApplication().popScreen(this);
            UiApplication.getUiApplication().pushScreen(new Screen3());
        }
    }
    
    //SCREEN 3 INPUTS *COMPOUND PERIOD*
    
    package com.rim.samples.Finance;
    
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.MenuItem;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.BasicEditField;
    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.ObjectChoiceField;
    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;
    import net.rim.device.api.ui.decor.Border;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public class Screen3 extends MainScreen implements FieldChangeListener
    {
        //DECLARE MENU BUTTONS
        protected void makeMenu(Menu menu, int instance)
        {
            menu.add(_home);
            menu.add(_close);
        }
    
        private MenuItem _home = new MenuItem("Home Page", 110, 10)
        {
                public void run()
                {
                    onHome();
                }
        };
    
        public boolean onHome()
        {
            Dialog.alert("Homepage Selected");
            UiApplication.getUiApplication().popScreen(this);
            UiApplication.getUiApplication().pushScreen(new Screen1());
            return true;
        }
    
        private MenuItem _close = new MenuItem("Close", 110, 10)
        {
            public void run()
            {
                onClose();
            }
        };
    
        public boolean onClose()
        {
            Dialog.alert("Goodbye!");
            System.exit(0);
            return true;
        }
    
        //SCREEN 3 METHOD
        Screen3()
        {
    
            HorizontalFieldManager _fieldManagerTop = new HorizontalFieldManager();
            VerticalFieldManager _fieldManagerMiddle = new VerticalFieldManager();
            HorizontalFieldManager _fieldManagerBottom = new HorizontalFieldManager();
            HorizontalFieldManager _fieldManagerButton = new HorizontalFieldManager();
    
            //SET TITLE: FINANCIAL APPLICATION
            LabelField title = new LabelField ("Financial Application", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            Font titleFont = this.getFont().derive(Font.BOLD | Font.ITALIC);
            title.setFont(titleFont);
            setTitle(title);
    
            //SET PAGE & INFO TEXT
            LabelField _page = new LabelField("Page Three ~ Compound Period", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);;
            LabelField _info = new LabelField("\nNow please enter the compound period.\npress spacebar to go through the choices:", LabelField.USE_ALL_WIDTH);;
    
            //ADD FIELDS AND SEPARATORS
            add(_fieldManagerTop);
            add(new SeparatorField());
            add(_fieldManagerMiddle);
            add(new SeparatorField());
            add(_fieldManagerBottom);
            add(new SeparatorField());
            add(_fieldManagerButton);
    
            //OBJECT CHOICE FIELD
            String choicestrs[] = {"Weekly", "Bi-Weekly", "Monthly", "Quarterly", "Annually"};
            ObjectChoiceField choice = new ObjectChoiceField("Compound Period: ", choicestrs, 0);
    
            //ADD PAGE, INFO, OBJECT CHOIE TO FIELD
            _fieldManagerTop.add(_page);
            _fieldManagerMiddle.add(_info);
            _fieldManagerBottom.add(choice);
    
            //CREATE BUTTON TO NEXT PAGE
            ButtonField press2Button = new ButtonField("NEXT");
            press2Button.setChangeListener(this);
            _fieldManagerButton.add(press2Button);
    
        }
    
        //BUTTON FIELD CHANGE: ACTIONS
        public void fieldChanged(Field field, int context)
        {
            UiApplication.getUiApplication().popScreen(this);
            UiApplication.getUiApplication().pushScreen(new Screen4());
        }
    }
    
    //SCREEN 4 INPUTS *LENGTH OF INVESTMENT*
    
    package com.rim.samples.Finance;
    
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.MenuItem;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.XYEdges;
    import net.rim.device.api.ui.component.BasicEditField;
    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;
    import net.rim.device.api.ui.decor.Border;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public class Screen4 extends MainScreen implements FieldChangeListener
    {
        //DECLARE MENU BUTTONS
        protected void makeMenu(Menu menu, int instance)
        {
            menu.add(_home);
            menu.add(_close);
        }
    
        private MenuItem _home = new MenuItem("Home Page", 110, 10)
        {
                public void run()
                {
                    onHome();
                }
        };
    
        public boolean onHome()
        {
            Dialog.alert("Homepage Selected");
            UiApplication.getUiApplication().popScreen(this);
            UiApplication.getUiApplication().pushScreen(new Screen1());
            return true;
        }
    
        private MenuItem _close = new MenuItem("Close", 110, 10)
        {
            public void run()
            {
                onClose();
            }
        };
    
        public boolean onClose()
        {
            Dialog.alert("Goodbye!");
            System.exit(0);
            return true;
        }
    
        //SCREEN 4 METHOD
        Screen4()
        {
            HorizontalFieldManager _fieldManagerTop = new HorizontalFieldManager();
            VerticalFieldManager _fieldManagerMiddle = new VerticalFieldManager();
            HorizontalFieldManager _fieldManagerBottom = new HorizontalFieldManager();
            HorizontalFieldManager _fieldManagerButton = new HorizontalFieldManager();
    
            //SET TITLE: FINANCIAL APPLICATION
            LabelField title = new LabelField ("Financial Application", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            Font titleFont = this.getFont().derive(Font.BOLD | Font.ITALIC);
            title.setFont(titleFont);
            setTitle(title);
    
            //SET PAGE & INFO TEXT
            LabelField _page = new LabelField("Page Four ~ Investment Length", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            LabelField _info = new LabelField("\nNow please enter how long you will have this investment for?\nPlease enter the amount in months:", LabelField.USE_ALL_WIDTH);
    
            //INPUT FIELD W/ BORDER
            BasicEditField _input = new BasicEditField();
            XYEdges padding = new XYEdges(10, 10, 10, 10);
            int color = Color.DARKGREEN;
            int lineStyle = Border.STYLE_SOLID;
            Border inputBorder = BorderFactory.createRoundedBorder(padding, color, lineStyle);
            _input.setBorder(inputBorder);
    
            //ADD FIELDS AND SEPARATORS
            add(_fieldManagerTop);
            add(new SeparatorField());
            add(_fieldManagerMiddle);
            add(new SeparatorField());
            add(_fieldManagerBottom);
            add(new SeparatorField());
            add(_fieldManagerButton);
    
            //ADD PAGE, INFO, INPUT
            _fieldManagerTop.add(_page);
            _fieldManagerMiddle.add(_info);
            _fieldManagerBottom.add(_input);
    
            //CREATE BUTTON TO NEXT PAGE
            ButtonField pressButton = new ButtonField("NEXT");
            pressButton.setChangeListener(this);
            _fieldManagerButton.add(pressButton);
    
        }
    
        //BUTTON FIELD CHANGE: ACTIONS
        public void fieldChanged(Field field, int context)
        {
            UiApplication.getUiApplication().popScreen(this);
            UiApplication.getUiApplication().pushScreen(new InvestmentWorth());
        }
    }
    
    //INVESTMENT WORTH
    
    package com.rim.samples.Finance;
    
    import net.rim.device.api.ui.Color;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.Manager;
    import net.rim.device.api.ui.MenuItem;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.XYEdges;
    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;
    import net.rim.device.api.ui.decor.Border;
    import net.rim.device.api.ui.decor.BorderFactory;
    
    public class InvestmentWorth extends MainScreen
    {
    
        //DECLARE MENU BUTTONS
        protected void makeMenu(Menu menu, int instance)
        {
    
            menu.add(_close);
        }
        private MenuItem _close = new MenuItem("Close", 110, 10)
        {
            public void run()
            {
                onClose();
            }
        };
        public boolean onClose()
        {
            Dialog.alert("Goodbye!");
            System.exit(0);
            return true;
        }
    
        //SCREEN 1 METHOD
        InvestmentWorth()
        {
    
            HorizontalFieldManager _fieldManagerTop = new HorizontalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
            VerticalFieldManager _fieldManagerMiddle = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
            HorizontalFieldManager _fieldManagerBottom = new HorizontalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    
            //SET TITLE: FINANCIAL APPLICATION
            LabelField title = new LabelField ("Financial Application", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            Font titleFont = this.getFont().derive(Font.BOLD | Font.ITALIC);
            title.setFont(titleFont);
            setTitle(title);
    
            //SET PAGE & INFO TEXT
            LabelField _page = new LabelField("Homepage ~ Initial Investment", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);
            LabelField _info = new LabelField("\nHere is the worth of your investment:\n", LabelField.USE_ALL_WIDTH);
    
            //INPUT FIELD W/ BORDER
            LabelField _worth = new LabelField();
            XYEdges padding = new XYEdges(10, 10, 10, 10);
            int color = Color.BLACK;
            int lineStyle = Border.STYLE_SOLID;
            Border inputBorder = BorderFactory.createRoundedBorder(padding, color, lineStyle);
            _worth.setBorder(inputBorder);
    
            //ADD FIELDS AND SEPARATORS
            add(_fieldManagerTop);
            add(new SeparatorField());
            add(_fieldManagerMiddle);
            add(new SeparatorField());
            add(_fieldManagerBottom);
    
            //ADD PAGE, INFO, INPUT
            _fieldManagerTop.add(_page);
            _fieldManagerMiddle.add(_info);
            _fieldManagerBottom.add(_worth);
    
        }
    
    }
    

    So when I run on the emulator, on Blackbery 8520 SDK emulator, it doesn't let me scroll upwards on the first screen to see the rest of the text, it's like the cursor on the button sticks or editing field base so it wont allow to exceed upwards the button or basic edit field , but I can scroll between them.

    Second problem is trying to address (as defined in the first class) variables to different edit fields so when something is typed in (double), it is placed in the variable to use in the rest of the program.  I want to make sure the basic edit fields only allow "double" number entered, otherwise it displays a message 'incorrect type '.   Please help me with this, or give me some advice.

    I would REALLY appreciate it.

    LabelFields will display several lines later the OS, so maybe this isn't a problem.  However, LabelFields are by default not active, so you can't scroll on them.  RichTextFields are active by default.  So either change your LabelFields for et focusable (style LabelField.FOCUSABLE) pr change to RichTextField, as the previous poster suggested.

    I do not understand your second question, what are the numbers 'double '?

    However, I was watching the styles FILTER_ that you can use to BasicEditField or watch extending TextFilter to check the characters that they are entered.  I suspect TextFilter is the right way to go, but I've never done anything like this.  But having a good overview in this field and classes that extends.

  • Hide/show the ObjectChoiceField...

    Hello

    I have a screen that has hierarchical menus (ObjectChoiceFields).  For example, category, subcategory, and Type.

    Type of choice will fill a selection of the subcategory.  Same subcategory will be filled based on the selection of the category.  In some case there is no subcategories and Types for certain categories and so on for the subcategories.  In this scenario, OS 5 and above to show the space reserved for the empty ObjectChoiceFields.

    Is it possible to hide when I don't need them and show them only when I need it?

    I really apprecaite your answer.  If the solution is little complex so please give me an example on how to do it because I'm still growing in this area.

    Thank you very much in advance,

    Vincent

    It's actually a pretty common question.

    You can dynamically add and remove fields from managers, and when you do, these managers are re-built-out.

    It means finding a way to determine when you should add and/or remove the category and Type.  You can do this with a FieldChangeListener on the category field, will get called whenever the user switches to another choice in the categories available, you can add and delete (and repopulate) fields then, according to the selected index.

    The next problem is where to 'Add' them.  Normally, you just make one

    . Add ();

    but who's going to the field at the bottom of the Manager.  Another option is

    . Insert (, index);

    That you will get through the fields to the right place.

    How do detect you if the area has indeed been added.  General, I do the following

    Manager m = . getManager().

    If (m == null) {}

    has not been added

    } else {}

    has been added

    }

    I hope that you get.  As stated, this question was asked before, typically on the addition or deletion of checkboxFields.  If you want more search for this.

    Good luck.

  • ObjectChoiceField getSelectedIndex method always returns-1

    Hello

    I am facing a problem since these days, but I couldn't get an answer to the it from anywhere. I hope I can get the answer here:

    I have a screen that has Menu and ObjectChoiceField but when I want to extract the ObjectChoiceField getSelectedIndex, it always returns-1. I don't know why! The code is very simple. If please see this and tell me where I'm wrong:

    public class ConfigurationScreen extends MainScreen implements FieldChangeListener {
    
        private ObjectChoiceField list;
        private MyMenuItem save; // I have a class for this seperately.
        String [] cities ;
    
        public ConfigurationScreen ()
        {
               cities  = new String [] {"New York","London","Paris"};
               list = new ObjectChoiceField ("Cities :", cities);
               list.setChangeListener(this);
               this.add(list);
    
           save = new MyMenuItem("Save",1,0){
                 public void run ()
                 {
                     Dialog.alert(list.getSelectedIndex()+"");
                 }
             };
             this.addMenuItem(save);
    
        }
    
       public boolean onClose()
       {
           Dialog.alert(list.getSelectedIndex()+"");
           return true;
       }
        public void fieldChanged(Field field, int context)
        {
                int selectedIndex = list.getSelectedIndex();
                Dialog.alert(selectedIndex+"");
            }
    
        }
    
    }
    

    The code could have a few spelling mistakes, but there is no syntax error in it. I get-1 whereeve I call the method getSelectedIndex()!

    Help, please

    Try this. It worked for me. Tested on BB 9000 Simulator. JDE 4.6.

    public class ConfigurationScreen extends MainScreen implements FieldChangeListener
    {
    
        private ChoiceField list;
        String [] cities ;
    
        public ConfigurationScreen ()
        {
            cities  = new String [] {"New York","London","Paris"};
            list = new ObjectChoiceField ("Cities :", cities);
            list.setChangeListener(this);
            this.add(list);
        }
    
        public boolean onClose()
        {
            Dialog.alert(list.getSelectedIndex()+"");
            return true;
        }   
    
        public void fieldChanged(Field field, int context)
        {
            int selectedIndex = list.getSelectedIndex();
            Dialog.alert(selectedIndex+"");
        }
    }
    
  • problem compiling under JDE 4.6

    I got this error when compile my project 4.3 to 4.6

    C:\Program Research In Motion\BlackBerry JDE 4.3.0\samples\com\rim\samples\device\TestApp\DialScreen.java:159: cannot access net.rim.device.api.ui.component.ListFieldMeasureCallback
    file not found net\rim\device\api\ui\component\ListFieldMeasureCallback.class
    private class MyObjectListField extends ObjectListField {}

    This error can be triggered by the expansion of some areas such as the ObjectChoiceField.  We are aware of this problem and it was reported to our development team.

Maybe you are looking for