HorizontalFieldManager

Call me a maniac of perfectionism.

I can't have a HorizontalFieldManager inside a VerticalFieldManager.

I did this:

 vfm.add(_lfCourses); 

vfm.add(body2); 

vfm.add(body3);  HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.USE_ALL_HEIGHT | Manager.FIELD_BOTTOM); hfm.add(ContactButton); 

hfm.add(DownloadButton); add(vfm); add(hfm);

But he won't put the buttons next to the other as shown in the attached photo.

What am I doing wrong again?

VFM. Add (HFM);
Add (VFM);

Tags: BlackBerry Developers

Similar Questions

  • HorizontalFieldManager custom: cannot field presentation, insufficient height or width

    I have two fields to label that I need for available side by side in a manager of horizontal field. When ran, the outputs of the Console: "cannot the field presentation, insufficient height or width.

    When I insert a breakpoint, the values are:

    • width = 480
    • height = 1073741823

    Why is the value of great height? (Oh yes, the virtual height.)

    What is the right way to calculate the height - just use the height field's favorite?

    LabelField lf = new LabelField("Flavor");
    LabelField olf = new LabelField("Order");
    
    HorizontalFieldManager hfm = new HorizontalFieldManager(
            Manager.NO_HORIZONTAL_SCROLL
                    | Manager.NO_HORIZONTAL_SCROLLBAR) {
    
            protected void sublayout(int width,
                int height) {
            Field field;
            int numberOfFields = getFieldCount();
            int x = 0;
            int y = 0;
    
            for (int i = 0; i < numberOfFields; i++) {
                field = getField(i);
                setPositionChild(field, x, y);
                layoutChild(field, width,
                        height);
                y += 10;
            }
    
            int myWidth = Math.min(width,
                    getPreferredWidth());
            int myHeight = height;
    
            super.sublayout(myWidth, myHeight);
    
            setExtent(myWidth, myHeight);
        }
    
        public int getPreferredWidth() {
            return getScreen().getWidth();
        }
    };
    
    hfm.add(olf);
    hfm.add(lf);
    

    You all that hard work the fields chickens and then try to destroy with super.sublayout () call. I'm sure that's what throws the exception. Check your myWidth and myHeight before the call to super.sublayout (). You might find that getPreferredWidth() returns to zero.

    I don't know why you would want to increase the parameter y in a horizontal field in any event handler. If anything, set x and not just randomly, by 10, but by the field.getWidth (). But it's logical that if you extend the Manager and remove super.sublayout call.

    More important still, you can get what you want much easier to not the substitution of all sublayouts and instead use setMargin on your domains.

  • Fixed HorizontalFieldManager Albums

    Hello

    I'm doing a top fixed banner (HorizontalFieldManager), style facebook/twitter, but I have no idea how do:

    I have tired:

    fmt=new HorizontalFieldManager(Manager.USE_ALL_WIDTH | Manager.NO_VERTICAL_SCROLL );
    

    But it did not work, the Manager moves upward when I scroll down.

    Hope you guys can help me.

    In addition, how can I Center all the buttons inside the HorizontalFieldManager?

    Welcome to the forum.

    What you ask is not trivial and will require a bit of reading as well as essays and substantive errors.

    Start by reading from this base.

    http://supportforums.BlackBerry.com/T5/Java-development/MainScreen-explained/Ta-p/606644

    http://supportforums.BlackBerry.com/T5/Java-development/create-a-custom-layout-manager-for-a-screen/...

    http://supportforums.BlackBerry.com/T5/Java-development/how-to-extend-Manager/Ta-p/446749

    Once you have been through this, so try a few options and ask questions.

    I'm not aware of a KB article or thread on this forum that corresponds exactly to your needs, but there are lots of similar questions, so search the Forum to find answers too.

    Good luck.

  • BasicEditFields will not be displayed in HorizontalFieldManager

    I have 3 BasicEditFields next to each other, but when I place it in a HorizontalFIeldManager, one appears where it should be on the left, but the other two do not.

    Any ideas on how I can fix this? Thank you.

    Scott

    QCB is correct, that basiceditfields do not play fair, because they will be the default use full width, which doesn't leave much space for the remaining fields.

    You have two choices:

    (a) BasicEditField override to limit the used width - you can do this by substituting the layout and getPreferredWidth.  There are a lot of similar questions on the forum, I'm sure if you search you can find another person who posted code that does.

    (b) change you Layout Manager so that it restricts the width that it helps the BasicEditField.  The TableLayoutManager sample provided by RIM (see the knowledge base) shows an example of this.

    Which of these two approaches you choose will depend on the conditions of Application.

    Note that you must take into account what happens on a storm in Portrait modes and landscape.

  • Set the color for emphasis on the interactive whiteboard to HorizontalFieldManager

    I have an array of horizontal fields that contains a bitmap and a labelfield each. The entire line should be clickable who worked until now, but how do I set the color to accent properly? At the moment the onFocus and onUnfocus functions are completely ignored.

    It's the definition of my table:

    for (int i = 0; i < listSize; i++) {
            logInDetailManager[i] = new HorizontalFieldManager(
                    Manager.USE_ALL_WIDTH | Field.FOCUSABLE) {
    
                protected void onFocus(int direction) {
                    super.onFocus(direction);
                    background_color = Color.RED;
                    invalidate();
                }
    
                protected void onUnfocus() {
                    invalidate();
                    background_color = Color.GREEN;
                }
    

    And that's how I add my horizontal fields:

    logInDetailManager[i].setChangeListener(this);
    logInDetailManager[i].add(dummyIcon[i]);
    logInDetailManager[i].add(new LabelField("hello"));
    logInDetailManager[i].add(new NullField(Field.FOCUSABLE));
    add(logInDetailManager[i]);
    

    Thanks for your help!

    AAH it got already...

    If someone has trouble with this too: I removed onFocus() and onUnfocus and set the background color in the paint so the color of the entire line method is modified when:

    protected void paint(Graphics graphics) {
    
        graphics.setBackgroundColor(isFocus() ? Color.RED : Color.GREEN);
        graphics.clear();
        invalidate();
        super.paint(graphics);
    }
    
  • horizontalfieldmanager limitation

    I just found out that HorizontalFieldManager can not add more than 1 TextField... When I add 2 TextField in a HorizontalFieldManager and then, I transfer the app to my Blackberry, second TextField will not be displayed. Is there such a restriction for some managers?

    This is not a limitation of the Manager, but a problem of the field, it signals a preferredWidth of unlimited and as a hfm has unlimited width (virtually) it grants this wish.

    You can replace getPreferredWidth on the domain or use a custom layout manager.

  • 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

  • How do HorizontalFieldManager containing buttons &amp; edit fields?

    Hello

    I tried welcoming two EditFields and a ButtonField to a HorizontalFieldManager. But only the first EditField is visible and a part of the button. The second EditField is completely invisible. I add this HorizontalFieldManager to a PopupScreen. I have to add two more HFMs llike this. Please see the code.

    fieldSortName = new EditField("SortName:", "", 10, Field.FOCUSABLE);
    fieldCustNo = new EditField("CustNo:", "", 5, Field.FOCUSABLE);
    buttonBrowse1 = new ButtonField("..", Field.FOCUSABLE);
    
    HorizontalFieldManager horsnMgr = new HorizontalFieldManager(Manager.FIELD_HCENTER){
     protected void sublayout(int maxWidth, int maxHeight)
     {
       layoutChild(fieldSortName, fieldSortName.getPreferredWidth(), fieldSortName.getHeight());
       setPositionChild(fieldSortName, 0, 0);
       layoutChild(buttonBrowse1, fieldSortName.getWidth(), buttonBrowse1.getHeight());
       setPositionChild(buttonBrowse1, Display.getWidth()/2, 0);
       layoutChild(fieldCustNo, fieldCustNo.getWidth(), fieldCustNo.getPreferredHeight());
       setPositionChild(fieldCustNo, maxWidth - fieldCustNo.getWidth(), 0);
       setExtent(maxWidth, fieldCustNo.getHeight());
     }};
    horsnMgr.add(fieldSortName);
    horsnMgr.add(buttonBrowse1);
    horsnMgr.add(fieldCustNo);
    vMgr_Main.add(horsnMgr);
    

    Any help will be very appreciated!

    screen_width = Display.getWidth();
    field_width = screen_width/3+1;
    
    fieldSortName = new EditField("SortName:", "", 10, Field.FOCUSABLE);
    fieldCustNo = new EditField("CustNo:", "", 5, Field.FOCUSABLE);
    buttonBrowse1 = new ButtonField("..", Field.FOCUSABLE);
    
    TableLayoutManager tlm = new TableLayoutManager(new int[]
    {
        TableLayoutManager.FIXED_WIDTH,
        TableLayoutManager.FIXED_WIDTH,
        TableLayoutManager.FIXED_WIDTH,
    }, new int[]{
             field_width,
             field_width,
             field_width,
    }, 0, Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR | FIELD_HCENTER | FIELD_VCENTER);
    
    tlm.add(fieldSortName);
    tlm.add(buttonBrowse1);
    tlm.add(fieldCustNo);
    add(tlm);
    

    Did the same thing yesterday, but with three buttons...  I used the TableLayoutManager.

  • HorizontalFieldManager problem

    I want to add fields to the horizontalFieldManager by defining their position as

    HorizontalFieldManager never respect the horizontal alignment - of course, because he has his own approach to horizontal placement. The best thing to do then import the JustifiedEvenlySpacedHorizontalFieldManager of

    Implement advanced buttons, fields and managers

    The code has a multitude of other great user interface code, so be sure to keep somewhere very practice.

    You can also experiment with setting the margins on your domains or creating fields of spacer and adding spacers Fluxsol between your gadgets actually used.

  • DateField, HorizontalFieldManager + ObjectChoiceField = error

    I am creating a page layout so that there a datefield and objectchoicefield in the horizontalfieldmanger even, and it throws me illegalarguementexception every time. Can someone help me? Here is the code example.

    HFM HorizontalFieldManager = new HorizontalFieldManager();
    HFM. Add (new DateField ("Some Text:", Date () .getTime (new),))
    DateFormat.getInstance (DateFormat.TIME_DEFAULT)));

    HFM. Add (new ObjectChoiceField ("", new String [] {"some", "text"}));
    Add (HFM);

    The problem here is that the DateField occupies the entire width.  The ObjectChoiceField then try to deal itself.  He seems to be referring to the treatment of layout of a RichTextField and pass the width that it must work, and the string to be converted (in this case, it is "a little").  RichTextField barfs with an Exception, because there is no way that 'some' can fit in the space provided (-1 pixel).

    To get this working, you have to find a way to limit bandwidth claiming the DateField.  I thought you'd be able to do by indicating the field to put his time left (style == DateField.FIELD_LEFT, but which did not work, so I went back to my usual substitutions and created what follows, that works.)

    You can take it from here?

    HFM HorizontalFieldManager = new HorizontalFieldManager();
    HFM. Add (new DateField ("Some Text:", System.currentTimeMillis (),))
    {DateFormat.getInstance (DateFormat.TIME_DEFAULT))}
    public int getPreferredWidth() {}
    Return to 150;
    }
    Protected Sub layout (int width, int height) {}
    Super.Layout (getPreferredWidth (), height);
    }
    });
    HFM. Add (new ObjectChoiceField ("", new String [] {"some", "text"}));
    Add (HFM);

  • Question of width for HorizontalFieldManager nin BB OS 6.0 and 7.0

    Hi all

    I developed a new application for BB OS 5.0, 6.0 and 7.0, which in its homepage has a bar containing different categories of navigation. The navigation bar is designed as:

    public HeaderMenu (String [] categories, HeaderMenuListener listCallback) {}
    Super(NO_HORIZONTAL_SCROLL |) NO_HORIZONTAL_SCROLLBAR | FOCUSABLE);
            
    mCategories = categories;
    mNewsListCallback = listCallback;
    mButtons = new CustomButton [mCategories.length];
    noOfCategories = mCategories.length;
    ND = this;
            
    mCategoryNavigator = new HorizontalFieldManager(FOCUSABLE |) HORIZONTAL_SCROLL |       HORIZONTAL_SCROLLBAR) {}

    public int getPreferredWidth() {}
    If (noOfCategories > 1) {}
    navigatorWidth = Display.getWidth () - mLeftNavigator.getWidth () - mRightNavigator.getWidth ();
    return Display.getWidth () - mLeftNavigator.getWidth () - mRightNavigator.getWidth ();
    }
    else {}
    Return Display.getWidth ();
    }
    };
                
    protected void sublayout (int maxWidth, maxHeight int) {}
    Super.sublayout (maxWidth, maxHeight);
    setExtent (getPreferredWidth (), getPreferredHeight());
    };
                
    };
    loadCategoryView();

    mLeftNavigator = new BitmapField (AppResolutionVariables.mLeftNavigationBtn, NON_FOCUSABLE);
    mRightNavigator = new BitmapField (AppResolutionVariables.mRightNavigationBtn, NON_FOCUSABLE);

    If (noOfCategories > 1)
    {
    Add (mLeftNavigator);
    }
    Add (mCategoryNavigator);
    If (noOfCategories > 1)
    {
    Add (mRightNavigator);
    }
    this.setBackground (BackgroundFactory.createSolidBackground (COLOR_MAROON));
    }
        
    /**
    The method of loading of new categories in a scroll handler.
    */
    private void loadCategoryView() {}
            
    int size = mCategories.length;
            
    Added table of buttons representative of the new categories to the Manager of scrolling.
    for (int i = 0; i)<>
    String categoryName = mCategories [i];
    mButtons [i] = new CustomButton (categoryName, DATA_FONT_BOLD, DATA_FONT_PLAIN,
    COLOR_MAROON, COLOR_WHITE) {}
                    
    public int getPreferredHeight() {}
    Return AppResolutionVariables.mLeftNavigationBtn.getHeight ();
    };
                    
    protected boolean navigationClick (int status, int time) {}
    int index = Arrays.getIndex (mButtons, this);
    If (index > = 0) {}
    mNewsListCallback.notifyHeaderButtonClick (index);
    }
    Returns true;
    }
    };
    mCategoryNavigator.add (mButtons [i]);
    }
    }

    Method takes care of asking left and right navigation buttons and scrollable Manager in the correct position.
    protected void sublayout (int maxWidth, maxHeight int) {}
            
    Super.sublayout (maxWidth, maxHeight);
    setExtent (getPreferredWidth (), getPreferredHeight());
            
    If (noOfCategories > 1) {}
    layoutChild (mLeftNavigator, maxWidth, maxHeight);
    setPositionChild (mLeftNavigator, 0, 0);
    }
            
    layoutChild (mCategoryNavigator, maxWidth, maxHeight);
    If (noOfCategories > 1) {}
    setPositionChild (mCategoryNavigator, mLeftNavigator.getWidth (), 0);
    } else {}
    setPositionChild (mCategoryNavigator, 15, 0);
    }
            
    If (noOfCategories > 1) {}
    layoutChild (mRightNavigator, maxWidth, maxHeight);
    setPositionChild (mRightNavigator, getPreferredWidth() - mRightNavigator.getWidth (), 0);
    }
    }

    The question do face is, when I scroll horizontally to the last button at the side bar, the last button is not visible completely, it becomes hidden by the right navigation button on the far right of HFM. This issue is in OS 6.0 and 7.0, but not in OS 5.0.

    Earlier, I had the problem in OS 5.0 so to fix it, I prevail on HFM getPreferredWidth() scrolling above, to return the width (width width HFM - width of navigation left button - not with the right navigation button scrolling) and it works fine. Can someone please fix the problem. Thanks in advance.

    Sorry just looking quickly here.

    The question which I believe is in your sublayout.  You tell your mCategoryNavigator field is the maximum width.  This isn't.  There only the width rest once the buttons have been added.

    There are two ways you can solve the problem.

    The simple way is just to spend the maximum width in the super.sublayout for mCategoryNavigator and no maxWidth.

    But the best way is to remove this sublayout completely and in your sublayout for the Manager.  In this handler, the layout and position your two buttons, then give the drop-down field which remains as its maximum width.

    Two other comments:

    (a) I would like to forget calling super.layout in your HeaderMenu and make everything in your own sublayout.  It would be a good exercise.  Remember the last thing you do is a setExtent, once you have placed all and so that you know how much space you need.

    (b) If you never call super.layout and then do a setExtent to get the correct size, the alarm should sound.  It's a bit like someone who gives a piece of paper, asking them to draw a picture and then decide that in fact the piece of paper is a different size of paper, that they needed to make the drawing.  You are actually asking someone else to do something and then ignoring what they have done (or at least a part of it).  If you find that you need to do, then look for another way as setExtent substitution causes the sorts of problems you found.

  • How to avoid the HorizontalFieldManager who is clicked

    I added a footer image on my setStatus() and this image, I used a HorizontalFieldManager that contains two buttons.

    When I click on the footer image, the button is clicked I don't understand why. Help, please.

    Here is the code:

    //In my main screen
    
    setStatus(footerStatus(getButtonBar()));
    
    ...
    
    public Field getButtonBar(){
    HorizontalFieldManager hfm1 = new HorizontalFieldManager(USE_ALL_WIDTH|Manager.NO_HORIZONTAL_SCROLL|Manager.NO_HORIZONTAL_SCROLLBAR);
    
    backButton.setMargin(DeviceManager.getBackButtonTopMargin(),0,0,DeviceManager.getBackButtonLeftMargin());
            nextButton.setMargin(DeviceManager.getNextButtonTopMargin(),0,0,DeviceManager.getNextButtonLeftMargin(nextBtnLeftMargin));
        hfm1.add(backButton);
        hfm1.add(nextButton);
        return hfm1;
    }
    
    ...
    
    public Field footerStatus(Field button) {
    Bitmap bm = Bitmap.getBitmapResource("img/footer.PNG");
    
    HorizontalFieldManager hfm0 = new HorizontalFieldManager(USE_ALL_WIDTH|Manager.NO_HORIZONTAL_SCROLL|Manager.NO_HORIZONTAL_SCROLLBAR);
    
    Background bg = BackgroundFactory.createBitmapBackground(bm, Background.POSITION_X_LEFT, Background.POSITION_Y_BOTTOM, Background.REPEAT_SCALE_TO_FIT);
        hfm0.setBackground(bg);
        hfm0.add(button);
        return hfm0;
    }
    

    When you touch a spot on the screen, the system searches for an active field in the field that touched you and direct your click here.  If it does not find it, he will lead the field in short read.  If you want to ignore these, you must remove clicks when the initiator device is outside your field.  Here is a code example:

    int x = message.getX (1);

    int y = message.getY (1);

    if (x < 0="" ||="" y=""> < 0="" ||="" x=""> getExtent () .width: y > getExtent () .height) {

    Outside the scope

    return fake;

    }

  • help with my HorizontalFieldManager &amp; EditFields on the same line, 2nd column is not displayed

    Hi all, I've written a bean (called LabelAndEditField) that sets out a label and editfield as follows

    someLabel

    _________________

    |                                 |

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

    It seems to work perfectly when it is the only component on a line of a

    VerticalFieldManager

    now I want to reuse this compenent such that I can have a screen that looks like

    someLabel another label

    ______________              ______________

    |                                 |             |                                |

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

    and perhaps a third column.

    However, when you add my components of LabelAndEditField, the 2nd does not appear

    I used a HorizontalFieldManager and make

    HFM HorizontalFieldManager = new HorizontalFieldManager();

    HFM. Add (new LabelAndEditField ("someLabel"));

    HFM. Add (new LabelAndEditField ("another label"));

    then I just on the screen

    Add (hfm);

    but it does not show my second column, the second component of the LabelAndEditField

    Here is the snippet of code below, some can please help me get this to display

    (Sorry, that the code of my insert is wacked)

    public class LabelAndEditField extends VerticalFieldManager
    {
        private EditField _editField;
    
        public LabelAndEditField(String label,
                                 String initialValueOfTextField,
                                 int maxChars,
                                 long style)
        {
            super(NO_HORIZONTAL_SCROLL);
    
            add(labelField);
    
            HorizontalFieldManager textMgr = new HorizontalFieldManager(
                    Manager.NO_HORIZONTAL_SCROLL
                    | Manager.NO_HORIZONTAL_SCROLLBAR);
    
            _editField = new EditField("", initialValueOfTextField, maxChars,
                         style | EditField.NO_NEWLINE | EditField.FOCUSABLE
                         | EditField.NON_SPELLCHECKABLE
                         | Field.FIELD_VCENTER | Field.FIELD_LEFT);
    
            textMgr.add(_editField);
    
            add(textMgr);
    
        }
    
    }
    

    and the code that adds as that on the screen

    super(NO_HORIZONTAL_SCROLL); // this is a VerticalFieldManager
    
    HorizontalFieldManager rowMgr =
         new HorizontalFieldManager(Manager.NO_HORIZONTAL_SCROLL
                 | Manager.NO_HORIZONTAL_SCROLLBAR);
    
    LabelAndEditField col1=
           new LabelAndEditField("some label","initial value",12,Field.READONLY);
    
        LabelAndEditField col2=
           new LabelAndEditField("another some label","initial value",12,Field.READONLY);
    
    rowMgr.add(col1);
    rowMgr.add(col2);
    

    did anyone see anything wrong with that?

    As you can see for yourself, there is no place for the mktShare.  Try to go with FlowFieldManager and no HorizontalFieldManager as a container for your gadgets MyLabelAndEditField and see

    There is another possibility:

    The key in the code I provided is the super.layout (myWidth, maxHeight).  This myWidth tells your EditField its maximum size in pixels.  If you want to further restrict the domain, you have several options.  The only problem is - if you limit it too much, you will not be able to see the rest of the field.  To solve this, wrap your EditField (in which you now don't have to override the layout) in a HorizontalFieldManager (HORIZONTAL_SCROLL) (all this inside your MyLabelAndEditField) and limit the Manager rather than the field itself.  Then your customer will be able to scroll through the left field and right.

    In order to limit your HorizontalFieldManager, give him the width that you want in pixels (add that, as a parameter to the constructor of your MyLabelAndEditField) and substitute his sublayout like this:

    HorizontalFieldManager textMgr = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR) {
      protected void sublayout(int maxWidth, int maxHeight) {
        int myWidth = Math.min(_desiredWidth, maxWidth);
        super.sublayout(myWidth, maxHeight);
      }
    };
    

    Thanks to his style HORIZONTAL_SCROLL, the infield will be almost infinite width, so the EditField inside fortunately "will display" all his characters.

    Then, when you design your MyLabelAndEditField, give him a maximum pixel value.  Say, you want three areas in a row.  Take your Display.getWidth (), subtract the margins planned, divide by 3 and pass that value to each of these areas.  Then add them to a HorizontalFieldManager (line2mgr in your example) and check the result.

    You seem to be competent enough to easily integrate my illegible bubbles in your code - let us know the results.

  • HorizontalFieldManager question

    I have the following text for the day of the week display boxes

    public HorizontalFieldManager ffm_days = new HorizontalFieldManager (Field.FIELD_LEFT);

    ffm_days. Add (Days [i])

    This.Add (ffm_days)

    This works very well on all operating systems, but NOT on the OS6.

    the screen would display the following boxes horizontally

    S M T W T F S

    but the torch, it shows that S box and reset are somewhere on the right side which I can't scroll or see.

    What is the best way to get boxes grouped and displayed horizontally? THX

    On the 6.0 check boxes using any of the default width.

    You must override the method of layout of boxes and set its measurement getPreferredWidth() box so that the same behavior than 5.0 and below.

    This hotfix does not break the previous OS impl. or the other.

  • How to make a black background for a horizontalFieldManager?

    I have a custom HorizontalFieldManager that bears a label for the field. I want the background of the black horizontalField Manager. How can I do?

    Please help me...

    Unless you develop only for 4.6 + devices, setBackground won't help you (this set appeared in 4.6.0).

    The cleanest way will be

    protected void paintBackground(Graphics g) {
      int prevBgColor = g.getBackgroundColor();
      g.setBackgroundColor(Color.BLACK);
      g.clear();
      g.setBackgroundcolor(prevBgColor);
    }
    

    However, you also want to ensure that the text on your LabelField is visible, as prash_bb_dev pointed out.  Either have the LabelField use, say, white background (same solution in a different place, replace Color.BLACK with Color.WHITE ) or indeed set white color inside of object and call the super.paint ().

Maybe you are looking for