Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8887059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:42:45+00:00 2026-06-14T21:42:45+00:00

I have a seemingly simple problem: I want to create 7 check-boxes (for the

  • 0

I have a seemingly simple problem:

I want to create 7 check-boxes (for the days of the week) lined up on 1 line using a
horizontal field manager. Unfortunately a CheckboxField, by default, takes up the whole line. Due to this, CheckboxField SHOULD (and according to the javadoc it does) have a style setting that makes it use only the width it needs. However, my compiler (Eclipse Plug-In) does not recognize “CheckboxField.NO_USE_ALL_WIDTH” and doesn’t compile/package my app.

The CheckboxField declerations:

private CheckboxField   cf_sun,
                        cf_mon,
                        cf_tue,
                        cf_wed,
                        cf_thu,
                        cf_fri,
                        cf_sat;

I defined my checkboxes as follows:

cf_sun = new CheckboxField("Sun", false, CheckboxField.NO_USE_ALL_WIDTH); // <-- ERROR
        cf_mon = new CheckboxField("Mon", false);
        cf_tue = new CheckboxField("Tue", false);
        cf_wed = new CheckboxField("Wed", false);
        cf_thu = new CheckboxField("Thu", false);
        cf_fri = new CheckboxField("Fri", false);
        cf_sat = new CheckboxField("Sat", false);

How could I make this work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:42:47+00:00Added an answer on June 14, 2026 at 9:42 pm

    According to the BlackBerry Javadocs on CheckboxField:

    NO_USE_ALL_WIDTH

    public static final long NO_USE_ALL_WIDTH

    Use this style to indicate
    the field should use only as much horizontal space as necessary.

    See Also: Constant Field Values

    Since: BlackBerry API 7.0.0

    Are you building your app against the SDK 7.0 libraries? Or something lower? If you use lower than 7.0, then the compiler (rightly) won’t find that new constant.

    Anyway, I tried your code on OS 5.0, and CheckboxField did not take up the whole line, if you add them all to a HorizontalFieldManager. But, let’s say that you do need more control over the field width …

    Luckily, it looks like you have a pretty simple layout. All your fields labels are the same length (3 chars), so you can probably just create a new subclass that sets the width. If you want it to be more dynamic, then you could use Font.getAdvance() on the checkbox labels to determine exactly how wide each label is, and therefore, exactly how much space each field would need (accounting for the width of the checkbox, too, of course).

    private class MyCheckboxField extends CheckboxField {
    
      public MyCheckboxField(String label, boolean value) {
         super(label, value);
      }
    
      public int getPreferredWidth() {
         // 32 is just a constant to account for the checkbox itself ... 
         // ... make this whatever you like
         return getFont().getAdvance(getLabel()) + 32;
      }
    
      protected void layout(int width, int height) {
         super.layout(getPreferredWidth(), height);
         setExtent(getPreferredWidth(), getPreferredHeight());
      }
    
    }
    

    and then

    cf_mon = new MyCheckboxField("Mon", false);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Entity Framework 4.1 and have a seemingly simple requirement: I want to
I have a seemingly simple problem whereby I wish to reconcile two lists so
I have a seemingly simple problem, but I can't quite figure out a solution.
I have a seemingly simple problem, but an easy solution is alluding me. I
I'm stumped by a seemingly simple problem. In my ASP.NET page, I have a
I have a problem which appears when using Ubuntu Linux/Gnome, but seemingly not on
Good day once again. I have a (seemingly) simple problem. I'm trying to display
I have a seemingly simple problem of splitting a comma separated String into tokens,
I have a seemingly simple problem though i am unable to get my head
I have been trying to get this seemingly simple problem fixed for about half

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.