CheckBoxField]

Hello

I have a question for the use of CheckBoxField.

When I use CheckBoxField as below it works fine:

==============================

for (int cnt= 0; CNT < listofbusiness.length="" ;="">cnt++ )

{

System.out. println ("Adding CheckboxField for -" + listOfBusiness [cnt]);

Rows.Add (new CheckboxField (listOfBusiness [cnt], true));

}

==============================

But when I use as below, it does not work.

CheckBoxField [] chkBoxField;

for (int cnt= 0; CNT < listofbusiness.length="" ;="">cnt++ )

{

chkBoxField [cnt] = new CheckboxField (listOfBusiness [cnt], true);

Rows.Add (chkBoxField [cnt]);

Rows.Add (new CheckboxField (listOfBusiness [cnt], true));

}

Can you please tell me what's wrong is?

You must initialize the array.

CheckBoxField [] chkBoxField = new CheckBoxField [listOfBusiness.length];

Tags: BlackBerry Developers

Similar Questions

  • Change the color of the text of the CheckboxField?

    Hi all

    I want to change the color of my Checkboxfield default black to white label text. How can this be achieved?

    Thank you

    Try the override of the method object and changing colors.

  • Extending from CheckboxField

    I have this image selector I use because I'm stuck with 4.6.1 and FilePicker does not make an appearance until 5.0.0. So I extended the CheckboxField class and written methods of painting and the layout with this code

    protected void paint (Graphics pGraphics)

    {

    pGraphics.setColor (0x0000FF00);

    pGraphics.drawBitmap (0, 0, 75, 75, vImage, 0, 0);

    If (getChecked ())

    {

    pGraphics.fillRect (0, 0, 75, 10);

    pGraphics.fillRect (0, 0, 10, 75);

    pGraphics.fillRect (75, 65, 0, 10);

    pGraphics.fillRect (0, 65, 75, 10);

    }

    pGraphics.setColor (0x00000000);

    pGraphics.drawText (getLabel (), 80, 30);

    Layout (GetWidth (), 75);

    setExtent (getWidth (), 75);

    }

    protected Sub layout (width int, int height)

    {

    Super.Layout (width, 75);

     super.setExtent (width, 75);

    }

    Seems to work by program very well, but as you can see on the screenshot the focus highlighter (not the isSelected highlighter, just to be clear) is well off his mark, I want to be around the full text of the label or the entire image and the text.

    Anyone have any ideas on how to achieve this.

    Nevermind

    public Sub getFocusRect(XYRect pRect)

    {

    super.getFocusRect (pRect);

    pRect.set (0, 0, (int) vTargetWidth + getFont () .getAdvance (getLabel ()) + 5, (int) vTargetHeight);

    }

  • EditField and checkboxfield on the same line

    public CheckFileScreen()
        {
            vfm = new VerticalFieldManager();
            left = new HorizontalFieldManager( Field.FIELD_LEFT);
            right = new HorizontalFieldManager( Field.FIELD_RIGHT);
            _Id = new EditField("Id : ", "", 6, EditField.FILTER_NUMERIC);
            _check = new CheckboxField("check", false);
                    left.add(_Id);
            right.add(_check);
            vfm.add(left);
            vfm.add(right);
            add(vfm);
            add(new SeparatorField());
        }
    

    on my above code tries to _id and _check on the same line, but the screen has been mess up

    +---------------

    | ID:

    | # check

    +----------------

    I want to create has been

    +----------------------

    | ID: # check

    +-----------------------

    could someone help me with this?

    This is the first time make app with GUI

    Gentlemen.

    slow down, please!

    Absolutely, totally useless any Manager available personalized for that! In order to organize two or more fields in a 'line', you just all of them to the same HorizontalFieldManager! The manager then places them from left to right in the order that you add them.

    That said - you have a slight problem in your EditField. EditField is "width-hungry" - it consumes the entire width, it is given, do not leave anything for the rest fields. To combat that, to deceive him into thinking he's got less space. We will give him what he needs to label 6 larger figures (s '8' or '9's, not '1') and a space for the padding. We will then have something like:

    _Id = new EditField("Id : ", "", 6, EditField.FILTER_NUMERIC) {
      protected void layout(int width, int height) {
        Font myFont = getFont();
        int myWidth = myFont.getAdvance(getLabel()) + myFont.getAdvance("8") * 6 + myFont.getAdvance(" ");
        super.layout(Math.min(myWidth, width), height);
      }
    };
    _check = new CheckboxField("check", false);
    HorizontalFieldManager hfm = new HorizontalFieldManager();
    hfm.add(_Id);
    hfm.add(_check);
    add(hfm);
    

    Enjoy!

  • CheckboxField, on the same line with OS6

    Hello

    I'm testing my apps for compatibility with OS6.  I discovered that if I have more controls, and then another on the same line, behavior went from OS5.  The first control's display while the other controls are moved outside of the screen.  Any idea on how to solve this problem while keeping compatibility?  Here's the code I'm referring to:

    HorizontalFieldManager hfmOperator = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
    
    int intRightSpace = Display.getWidth()/10;
    
    LabelField lblOperator = new LabelField("");
    lblOperator.setFont(Font.getDefault().derive(Font.PLAIN, 18));
    lblOperator.setPadding(0, intRightSpace, 0, 0);
    hfmOperator.add(lblOperator);
    
    chkADD = new CheckboxField("+",  Param.boolActiveADD);
    chkADD.setFont(Font.getDefault().derive(Font.PLAIN, 24));
    chkADD.setPadding(0, intRightSpace, 0, 0);
    hfmOperator.add(chkADD);
    
    chkSUB = new CheckboxField("-",  Param.boolActiveSUB);
    chkSUB.setFont(Font.getDefault().derive(Font.PLAIN, 24));
    chkSUB.setPadding(0, intRightSpace, 0, 0);
    hfmOperator.add(chkSUB);
    
    chkMUL = new CheckboxField("*",  Param.boolActiveMUL);
    chkMUL.setFont(Font.getDefault().derive(Font.PLAIN, 24));
    chkMUL.setPadding(0, intRightSpace, 0, 0);
    hfmOperator.add(chkMUL);
    
    chkDIV = new CheckboxField("/",  Param.boolActiveDIV);
    chkDIV.setFont(Font.getDefault().derive(Font.PLAIN, 24));
    chkDIV.setPadding(0, intRightSpace, 0, 0);
    hfmOperator.add(chkDIV);
    
    add(hfmOperator);
    

    The only way I could get to this day is to override the method of layout in the CheckboxField and spend a fixed width to the super method:

    protected void layout(int width, int height) {
        super.layout(100, height);
    }
    

    The problem with this approach is that the width of the content can vary from a device to according to the size of font by default, etc. and it may be possible to try to force a specific width.

  • CheckBoxField question

    Hello!

    I want to add checkboxes in a dynamic way to the Senior Manager.

    while (reItems.hasNextElement())
                {
    ck1 = new CheckboxField(string, boolean);
    add(ck1);
    }
    

    Later, I want to get the value of each of them. How can I do?

    Go to table of checkbox fields.

    CheckboxField checkbox[];
    checkbox=new CheckboxField[size of your reItems];
    
    while(reItems.hasNextElement)
    {
         checkbox[value]=new CheckboxField("Name", false);
         add(checkbox[value]);
    }
    

    Then you can get the values of each.

  • CheckboxField [] and fieldChangeListener.

    Hello

    I need a dynamic number of checkboxes for a project I'm working on. My code example is as follows. Somehow, I get an jvm stackoverflow exception.

    public class abc() extends screen implements {FieldChangeListener}

    CheckboxField [] boxField;

    public abc() {}

    .

    .

    .

    the length is variable.

    boxField = new CheckboxField [length];

    VFM VerticalFieldManager = new VerticalFieldManager();

    for (int i = 0; i)

    boxField [i] = new CheckboxField();

    boxField [i] .setChangeListener (this);

    VFM. Add (boxField [i]);

    }

    Add (VFM);

    }

    Sub fieldChanged (field field, int context) {}

    Hardcode for now. The intention is to loop through and uncheck all

    except one who was just ticked.

    chkBoxField [0] .setChecked (false); StackOverflow exception

    }

    }

    Help?

    In this way:

    chkBoxField [0] .setChecked (false);

    You set the value of the checkbox, prompting to advise its FieldChangeListener, which is to set the value of the box, which advises the FieldChangeListener... I could go on.   Until what I stack overflowed of course.

    Although there are many ways to stop this, I think that you should be aware of using the context provided to the fieldChanged method.  To check

    FieldChangeListener.PROGRAMMATIC

    If it matches, then the change was made by a program and not by the user, in which case you should ignore the change.

    For example:

    Sub fieldChanged (field field, int context) {}

    If (context == FieldChangeListener.PROGRAMMATIC) {}

    Only to process user changes to checkboxes

    return;

    }

    .....

    Hope it makes sense.

    Edit: this has been creating during the validation of RexDoug, my apologies for the repetition.

  • How do I know what checkboxfield is changed?

    How do I know when the checkboxfield (value true or false) is changed by the user?

    I want to receive event when the user changes the status of the checkboxfield.

    For example,.

    Sub UserChangedCheckboxfield()

    {

    Dialog.Alert ("you change the State of the checkbox");

    }

    Create a FieldChangeLIstener and attach it to the box field.

  • Alignment with CheckBoxField problems

    Hello

    I have just started to do some development BB and am pulling my hair out more try to right align a CheckBoxField.  What I do has no effect.

    mHeaderCB

    = new CheckboxField ("",false, Field.FIELD_RIGHT | ") Field.USE_ALL_WIDTH);

     

    The code above is how I create the object, this in turn is added to a horizontalfieldmanger, which in turn is also added to the horizontalfieldmanager.

    I develop this in Eclipse, targeting JDE 4.6.0.

    Can anyone help, something that should be as simple as it is very difficult.

    (new CheckboxField("",false,Field.FIELD_RIGHT));

    works when adding a verticalFieldManager.

    Who help me?

  • A set of CheckboxFields can be nested?

    My dear experts...

    Is it possible to nest a set of checkboxes in a form? I tried to put a checkbox inside a tree, but no use... However, I think that it is impossible...

    Thank you...

    Seems that it is not...

    Thank you.

  • When you close the popup only proceed

    Hello

    In my fieldChanged(), I ask a pop-up message. The popup has a close button that closes the popup. I don't want the application to perform the work until the context menu does not close. I am not able to do this. The code is:

        public void fieldChanged(Field f, int context) {
            System.out.println("Into ------------ BUTTON CLICKED = " + f + " C0NTEXT = " + context + " btnClicked = " + btnClicked);
            if (f instanceof CheckboxField) {
                CheckboxField cb = (CheckboxField) f;
                // Get details associated with the selected checkbox
                UiApplication.getUiApplication().invokeAndWait(new Runnable() {
                        public void run() {
                            getScreen().getUiEngine().pushScreen(new MessagePopup(mm1));
                            return;
                        }
                    });
                    // Change some data and invalidate
                    if (mm.read == false) {
                        mm.read = true;
                        cb.setCookie(mm);
                        unreadCount -= 1;
                        if (unreadCount < 0)
                            unreadCount = 0;
                        System.out.println("UNREADCOUNT =  " + unreadCount + " ******************* ");
                        inboxBtn.setText("Inbox " + unreadCount);
                        invalidate();
                    }
                    System.out.println("CheckBox Complete");
                 }
            }
    
       // POPUP CLASS
        class MessagePopup extends PopupScreen  implements FieldChangeListener  {
            private BitmapButtonField okBtn;
    
            public MessagePopup(MailMessage mm) {
                super(new VerticalFieldManager(VERTICAL_SCROLL | VERTICAL_SCROLLBAR));
                okBtn = new BitmapButtonField(Bitmap.getBitmapResource("res/cancel_btn.png"));
                okBtn.setChangeListener(this);
                add(new LabelField("Label "));
                add(okBtn);
            }
    
            public void fieldChanged(Field field, int context) {
                if (field == okBtn)
                    this.close();
            } 
    
            protected boolean keyChar(char key, int status, int time) {
                if (Keypad.KEY_ESCAPE == key) {
                    this.close();
                    return true;
                } else
                    return super.keyChar(key, status, time);
            }
        }
    

    The output is: popup appears and I see the following SOP

    CheckboxField Selected * READ = false *.
    UNREADCOUNT = 4 *.

    Complete box

    According to me, when I click on the Ok button in the pop-up window and then 2 lines that is below

    UNREADCOUNT = 4 *.

    Complete box

    must be executed.

    No idea how to work with this scenario. Any help is very appreciated.

    Thank you

    As I understand it, you don't want "if(mm.read == false)" to get executed until the screen closes?

    If this is correct then replace "pushScreen' by 'pushModalScreen '. Block screens mode until the screen is closed. You have not need surgery of invokeAndWait from the modal screen will block the execution anyway.

  • How to recover frm the checkbox value

    Hello

    How to recover frm the checkbox value

    can someone help me on this topic

    Thank you

    Sujith

    CheckboxField class

    Boolean getChecked()

  • several checkbox in horizontalfieldmanager problem!

    Hi, I add several checkbox in horizontal fieldmanager.

    It displays as intended for os 5 and less but only displays the first box added to os 6.

    I don't know what the problem is! Please tell me what I'm doing wrong, or give me a work-around!

    Code:

    check1 = new CheckboxField("1", true);
    check2 = new CheckboxField("2", true);
    check3 = new CheckboxField("3", true);
    
    checkField = new HorizontalFieldManager();
    
    checkField.add(check1);
    checkField.add(check2);
    checkField.add(check3);
    
    add(checkField);
    

    Thanks in advance!

    It seems that in CheckboxField became "width-hungry" the OS 6.  Check this thread for the solution:

    CheckboxField, on the same line with OS6

  • Can not edit in the area...

    Hi all

    I've coded some simple examples for the field and box but some how it is not editable.

    I just follow with an example.

    Can someone help me on this?

    Code is below.

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package com.heycosmo.MyConcierge;

    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 import. *;
    Import net.rim.device.api.ui.FieldChangeListener;
    import com.heycosmo.MyConcierge.ConnectionThread;

    /**
    *
    Bestway * @author
    */
    SerializableAttribute public class extends //implements screen KeyListener MyScreen
    {

    public logoBitmap Bitmap = null;
    Private final int MAX_EMAIL_NAME = 60;
    Private final int MAX_PASSWD = 20;
    Private ConnectionThread connThread;

    public AutoTextEditField emailTextField = new AutoTextEditField ("email:", "");
    public BasicEditField passwdTextField = new BasicEditField ("password:", "", MAX_PASSWD, BasicEditField.EDITABLE);
    private rememberMe new CheckboxField = CheckboxField ("Remember me", true);
    private CheckboxField signAuto = new CheckboxField ("Connect automatically", true);
    btnLogin private ButtonField = new ButtonField ("Login", / * Field.FOCUSABLE * / ButtonField.FIELD_HCENTER |) ButtonField.CONSUME_CLICK);
    private BitmapField btmField = null;
       
    public MyScreen (ConnectionThread connThread)
    {
    this.connThread = connThread;
           
    logoBitmap = Bitmap.getBitmapResource("login-img.png");
                 
    Add (new LabelField ("MyConcierge", LabelField.NON_FOCUSABLE |)) LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
    LabelField title = new LabelField ("MyConcierge", LabelField.ELLIPSIS |) LabelField.USE_ALL_WIDTH);
    setTitle (title);
           
              
    btmField = new BitmapField (logoBitmap);
           
    Add (btmField);
           
    Add (emailTextField);
    Add (passwdTextField);
           
    Add (new SeparatorField());
    Add (RememberMe);
    Add (signAuto);
           
    FieldListener sendListener = new FieldListener();
    btnLogin.setChangeListener (sendListener);
    Add (btnLogin);
    Add the vertical main Manager screen
                  
    Add key and wheel listeners to the screen
    addKeyListener (this);
    addTrackwheelListener (this);
           
                   
    }

    This problem is solved.

    I removed the public boolean keyChar (key char, int status, int time) in the class.

  • button would not update if you touch

    Hello

    Here is the screen of my problem:

    I can get the 'Run' button with the trackpad, and then click / touch and it works, but I would like to acquaire focus and get clicked just by the same touch to it she not currently have focus. Any way to achieve this?

    My constructor code:

    super(Screen.NO_VERTICAL_SCROLL);
    
            try
            {
                _odcSettings = new Settings();
    
                // Manager to lay out checkboxes
                ManagerSets vfm = new ManagerSets(USE_ALL_WIDTH);
                this.add(vfm);
    
                _iciNumbersField = new LabelField("I.C.I. Numbers: ");
                _iciNumbers011Field = new CheckboxField("011", _odcSettings.getPrefix1().length() > 0);
                _iciNumbersP1Field = new CheckboxField("+1", _odcSettings.getPrefix2().length() > 0);
    
                _autorunField = new LabelField("Autorun: ");
                _autorunGroup = new RadioButtonGroup();
                _autorunFieldOn = new RadioButtonField("Yes", _autorunGroup, _odcSettings.isAutostart());
                _autorunFieldOff = new RadioButtonField("No", _autorunGroup, !_odcSettings.isAutostart());
    
                _autosendField = new LabelField("Autosend password: ");
                _autosendGroup = new RadioButtonGroup();
                _autosendFieldOn = new RadioButtonField("Yes", _autosendGroup, _odcSettings.isSendDtmf());
                _autosendFieldOff = new RadioButtonField("No", _autosendGroup, !_odcSettings.isSendDtmf());
    
                _pwdField = new LabelField("Password: ");
                _pwdTextField = new PasswordEditField("", _odcSettings.getDtmf(), 16, PasswordEditField.FILTER_NUMERIC);
    
                _runField = new ButtonField("Run", Field.FIELD_HCENTER);
                _runField.setChangeListener(this);
    
                vfm.add(_iciNumbersField);
                vfm.add(_iciNumbers011Field);
                vfm.add(_iciNumbersP1Field);
                vfm.add(_autorunField);
                vfm.add(_autorunFieldOn);
                vfm.add(_autorunFieldOff);
                vfm.add(_autosendField);
                vfm.add(_autosendFieldOn);
                vfm.add(_autosendFieldOff);
                vfm.add(_pwdField);
                vfm.add(_pwdTextField);
                vfm.add(_runField);
    
            }  catch (Exception e) {
    
                e.printStackTrace();
            }
    

    Thank you!

    good tip.

    It worked for me:

      protected boolean touchEvent(TouchEvent event)    {     try       {         int index = vfm.getFieldAtLocation(event.getX(1), event.getY(1));
    
              switch(event.getEvent())          {             case TouchEvent.CLICK:                    if (vfm.getField(index) == _runField)                 {                     _runField.setFocus();                     _runField.forceClick();                   }             return true;           }
    
          } catch (Exception e) {           // TODO Auto-generated catch block            e.printStackTrace();      }
    
          return super.touchEvent(event);   }
    

Maybe you are looking for

  • HP laserjet 1020 doesn't print

    Windows 7 PRO 64-bit operating system The HP laserjet 1020 printer works on the above software? Tried to uninstall the printer drivers but failed. Message-installation met with an abnormal program execution. the installation program stops. It was usi

  • I get to gmail, but get then continuous "loading" message

    I use Firefox to access my gmail-have never had a problem until today. I get my google mail page but when I try to read an e-mail message in my Inbox I get a message that simply says "loading". Google says it's a Firefox problem? I downloaded an upgr

  • Ian@iTunes

    My iTunes has been locked because of overcapacity, what do I do to unlock it and resume playback of my music?

  • Access denied to Application data

    I need to move my Vista system Thunderbird e-mail files to an XP system.  On XP, I find the information in the Application data for the user in the Documents and Settings folder.  Here it is on Vista and I have to do anything special to access?

  • Director of office of blackBerry Smartphones has always updated

    First off I use the most recent operating system (OS 5.0.0.32 8). Whenever I'm plugging my storm into my computer and bring up to Desktop Manager he always tells me that "BlackBerry 5.0 Core Applications" has an update. I'm trying to "update" but sti