LabelField Scrollable

I have to show some information. If the information is more than one line, it will be automatically breaks into several lines. To do this, I created my own CustomLabelField. It works very well. But when I add several CustomLabelFields in a VerticalFieldManager of the labels underneath the screen, so I want to scroll to see these labels, I can't scroll. So I write this method:

    public boolean isFocusable()
    {
        return isFocusable;
    }

By doing this I can scroll. But this time, when a label is focused on the background are changes its color. I don't want to. I wan't color will stay the same and I can scroll. What is the best way to do it?

Thank you.

You realize that you can do a labelField focus using its constructor, for example:

My lab LabelField = new LabelField ("Test", LabelField.FOCUSABLE);

The only way I can think of (and I'm not an expert in the user interface, so there are likely to be other ways), is to replace the getFocusRect() and return as a rectanlge 0,0,0,0.  I tried this in 4.2.1 seemed to work.  But might not work for you, and I have no idea of the consequences.

        public void getFocusRect(XYRect rect) {
            // super.getFocusRect(rect);
            rect.width = 0;
            rect.height = 0;
        }

Just another thought, have you tried a RichTextField in place and place your LabelField?

Tags: BlackBerry Developers

Similar Questions

  • Highlight a label field.

    I have a label field on a screen that can hold a large amount of text which will disappear from the screen, how can I make cela scrollable?

    I tried to put the label in a VerticalFieldManager, but without success.

    Thank you

    First of all, please learn how to use the search box on the top of the screen.  If you are looking for 'LabelField' returned this thread as the first among others:

    LabelField Scrollable

    The thread gives a solution similar to swati srivastava's.  morpheusghost gives a slightly different resulting in almost the same visual appearance.

    However, none of these solutions is perfect.

    If the text in the field is greater than 2 screens (or the field Heights), jumping from the beginning to the end (that's what happens when divert you attention from the NullField first to the last NullField) never allow see her in the middle of your LabelField.  Consider using a TextField for longer texts.  Make it FOCUSABLE and READONLY and add it to a VerticalFieldManager with VERTICAL_SCROLL (and possibly VERTICAL_SCROLLBAR).  TextField and his descendants may have the focus within the field (the cursor).  That's how you let the user scroll.

    Otherwise, you can have no field focusable and manage the movements of navigation, using setVerticalScroll of the VerticalFieldManager containing your LabelField.  But that would require more code and is less intuitive.

  • labelfield not showing on screen text

    Hello

    I have the following behaviors on a label field added to a VerticalFieldManager.

    When the text on the label is greater(in heigth) the screen of the device, it assumes this 2 x times the height of the screen, a part of the text is not displayed because when scroll us to the bottom of the screen it cams directly at the end of the VerticalFieldManager. In this way we see that the first and the last part of the label, do not show all of the text of the label.

    I searched the forum for "scroll bars", but I have not found anything that could help me...

    Comment from arkadyz is the key to this:

    To scroll programmatically, use setVerticalScroll of your Manager and substitution, for example, navigationMovement for the user that controls. Search this forum for ideas - setVerticalScroll looks like a token of good research in your case.

    A labelField is not active by default.  so focus will jump over to below it.  On a touchscreen device is not a problem, because you can scroll without moving the cursor.  But when using the trackpad, it is a problem.

    Your best bet is to convert the labelField one RichTextField, make sure it is active, then development will move through the field and you will be able to move down one line at a time.

    Otherwise, take a look at this article that shows scrolling around another non-active field:

    http://supportforums.BlackBerry.com/T5/Java-development/create-a-scrollable-image-field/TA-p/444955

  • LabelField, 4.6 vs.5.0, is this a bug?

    Ok

    Here are simple custom LabelField:

    public class BitmapButtonField extends LabelField {
    
        private Bitmap BmOnFocus;
        private Bitmap BmOffFocus;
    
        public BitmapButtonField(long _style,                              Bitmap _onFocus,                              Bitmap _offFocus) {
            super("", _style);
            BmOnFocus = _onFocus;
            BmOffFocus = _offFocus;
        }
    
        public int getPreferredHeight() {
            return BmOnFocus.getHeight();
        }
        public int getPreferredWidth() {
            return BmOnFocus.getWidth();
        }
        protected void layout(int width, int height) {
            int h = getPreferredHeight();
            int w = getPreferredWidth();
            super.layout(w, h);
            setExtent(w, h);
        }
    ....
    };
    

    The 'problem' with this code is that it works OK when compiled and run under OS 5.0

    and gives error when compiled and running on 4.6.

    The error is that BmOnFocus has the value null when getPreferredWidth() is called!

    The use of this field as usual

    BitmapButtonField bfGame = new BitmapButtonField(Field.FOCUSABLE, imgGame, imgGameNS);
    add(bfGame);
    

    Looks like the 'bad' superdeal ("", _style ") name () of layoutand of course by this time bitmaps are not yet defined.

    But why it works on 5.0?

    Ok

    workaround was quite simple - I commented getPreferredWidth () /Height () methods

    and changed layout() for:

        protected void layout(int width, int height) {
            int h = BmOnFocus.getHeight();
            int w = BmOnFocus.getWidth();
            super.layout(w, h);
            setExtent(w, h);
        }
    

    In my case it was OK.

  • custom drawing LabelField problem

    Hello

    I want to do my own LabelField personalized and written that way...

    but it does not display a text...

    What is the problem...?

    where I'm wrong?

    SerializableAttribute public class BBLabelField extends {LabelField
    private string text;
    private int colorOfText;

    public BBLabelField (String text, int colorOfText) {}
    Super (Text);
    This.Text = text;
    this.colorOfText = colorOfText;

    }

    protected void paint (Graphics graphics) {}
    graphics.setColor (colorOfText);
    Super.Paint (Graphics);
    }

    }

    Thank you.

    Hi Swpanil,

    I found the solution...

    instead ofoverriding

    protected void paint ()... I need to replace

    public void object...

  • Help LabelField

    How to make a labelfield only select this text in brief (as rectangular selction blue) with the red color of the selected text?

    Thanks in advance

    Then, you will need to substitute drawFocus do nothing:

    protected void drawFocus(Graphics g, boolean on) {
    }
    
  • How do CONSUME_CLICK on a LabelField?

    Hello

    I listed suruneliste of names I used LabelField to display names. Now, I want to open a popup when the user clicks the labelfield. I can't find CONSUME_CLICK to use for LabelField. How to achieve it. ? I've already implemented navigationClick.

    The code so far I coded is:

        public static LabelField getClickableLabelField(String label) {
            LabelField lb = new LabelField(label, Field.FOCUSABLE | Field.FIELD_LEFT | Field.FIELD_VCENTER ) {
                public void paint(Graphics g){ g.setColor(Color.WHITE); super.paint(g); }
                protected boolean navigationclick(int status, int time) {
                    fieldChangeNotify(1);
                    return true;
                }
            };
            return lb;
        }
    
    IN THE IMEPLEMENTING CLASS :
    
                LabelField lf = Common.getClickableLabelField(nm);
                lf.setCookie(new Integer(i));
                lf.setChangeListener(this);
    
                public void fieldChanged(Field field, int context) {
                   if (field instanceof LabelField) {
                      LabelField lf = (LabelField) field;
                      // Wanted to check if this is the correct field or not
                      if (lf.isFocus())
                         System.out.println("YES HAS FOCUS, CORRECT ONE !!! Text = " + lf.getText());
                  }
                  return;
                }
    

    Can anyone help me know how to get the clicked labelfield and fieldNotify is called, and therefore the implementation class fieldChanged().

    Any help is very appreciated.

    Thank you

    Override navigationUnclick() to always return true.

  • Maximum width LabelField

    Hi, I'm sure that many applications that have lists have successfully done a certain way or another but I can't figure out how!

    The problem is, I listfield with labelfields in them and I want them to display the content in a single line. So if the text in the labelfield overflows, I won't display on multiple lines, but intersect at the end and be replaced by «...» »

    I considered the max character length in the labelfield but this would produce a contradictory result because each alphabet have different widths.

    I do not know how to approach this problem, is there a api for this kind of situation? Auto replace the remaining characters by «...» » ?

    There is a model for this; LabelField.ELLIPSIS

    (if I have the correct spelling)

    See the javadocs.

  • "LabelFields table" is this possible?

    I now get a NullPointerException when trying to do.
    Code:

    Static VerticalFieldManager table;

    private static LabelField LF1 [];
    private static LabelField LF2 [];
    public MyScreen() {}

    ....

    Table = new VerticalFieldManager();

    for (int i = 0; i)<>
    {
    Line HorizontalFieldManager = new HorizontalFieldManager();

    LF1 [i] = new LabelField("");   Application breaks here with a NullPointerException error
    LF2 [i] = new LabelField("");

    Row.Add (LF1 [i]);
    Row.Add (LF2 [i]);
    Table.Add (Row);
    }

    ...

    }

    Thanks in advance...

    Hello

    The problem is allocate memory for label fields IE

    Static VerticalFieldManager table;

    private static LabelField LF1 [];
    private static LabelField LF2 [];
    public MyScreen() {}

    ....

    Table = new VerticalFieldManager();

    LF1 = new LabelField [Functions.Records];
    LF2 = new LabelField [Functions.Records];

    for (int i = 0; i)<>
    {
    Line HorizontalFieldManager = new HorizontalFieldManager();

    LF1 [i] = new LabelField("");   Application breaks here with a NullPointerException error
    LF2 [i] = new LabelField("");

    Row.Add (LF1 [i]);
    Row.Add (LF2 [i]);
    Table.Add (Row);
    }

    ...

    }

    Kind regards

    Lachi...

  • How to make a LabelField align right when the text is long?

    In order to make a good LabelField aligned, I create the LabelField with style "FIELD_RIGHT and add it to a value for money, it works when the text can be displayed on a single line." But when the text is long, over a single line, it works well.

    For example, if the text is "ABDEL FARZAD", appears like this:

    It looks like aligned left

    How can I get it?

    .

    No guarantee, but instead of Field.RIGHT, try

    FIELD. USE_ALL_WIDTH | DrawStyle.RIGHT

  • Unable to change font size LabelField

    Regardless of the font size I put, it seems no effect and the font size does not change! I can change color but not the police. What's not in the code below?

    public class FMHorizSingleCont extends HorizontalFieldManager {}

    private LabelField lbDesc;

    public FMHorizSingleCont () {}

    lbDesc = new LabelField (title, LabelField.USE_ALL_WIDTH) {}

    Do police = Font.getDefault () .derive (Font.PLAIN, 6,Ui.) UNITS_pt);

    protected void paint (Graphics g) {do police = Font.getDefault ().derive(Font.PLAIN,6,Ui.UNITS_pt);}

    g.setFont (do);

    g.setColor (Color.BLACK);

    Invalidate();

    Super.paint (g);

    }

    };

    Add (lbDesc);

    Set the font under the method object.

    As:

    lbDesc = new LabelField(title, LabelField.USE_ALL_WIDTH)
    {
        protected void paint(Graphics g)
        {
           //Font font = Font.getDefault().derive(Font.PLAIN,6,Ui.UNITS_pt);
           //g.setFont(font);
           g.setColor(Color.BLACK);
           invalidate();
           super.paint(g);
        }
    };
    Font font = Font.getDefault().derive(Font.PLAIN,6,Ui.UNITS_pt);
    lbDesc.setFont(font);
    

    Concerning

    Bika

  • Put LabelField above BitmapField

    I searched around, but have not found a clear answer to this. The answers that are closer seem complicated for what should be a very simple thing to do

    What is the easiest way to place a LabelFeild on top a BitmapField? Specifically, I have the splash screen that takes the entire screen with a BitmapField, and I want to place a small LabelField in the lower right, on top of the Bitmap image. Am I crazy to think that this should be easier?

    I wrote once a code only one field of centers on a bitmap.  Change it to put the box down below is trivial. Here is the link to the code:

    ButtonField with background

    It is in the solution post. Watch the childX and childY calculations and remove the division by 2.

  • LabelField DrawStyle.RIGHT &amp; setText()

    Hi, I have a labelfield with DrawStyle.RIGHT then later, I put the text. Definition of the text, the DrawStyle is destroyed and is aligned to the left.

    Is - this expected outcome?

    Be aware that on a LabelField redispositions setText fullscreen. Make sure that manager that contains this field has not suddenly become smaller. LabelFields are economical in terms of use of space, so make sure that you have Field.USE_ALL_WIDTH or something similar and more of your DrawStyle.RIGHT flag.

    If you have a custom page/sublayout layout, make sure that it can survive further appeal after setText was called.

  • Set the font of a LabelField Arial

    How can I set the font to a LabelField Arial with a font size that is two points higher than the default font?

    I see that the setFont method can be used, but the argument is a cast and I can't understand how to create a font Arial.

    Also, I found that I can create a font using the:

    Do police = Font.getDefault ();

    But how can I determine the size of the default font so that I can put my Arial font to two more points?

    Thank you...

    FontFamily fontFam = FontFamily.forName("Arial");
    Font cFont = fontFam.getFont(FontFamily.SCALABLE_FONT, 8).derive(Font.BOLD);
    

    Code example

  • LabelFields in the pop-up screen centering

    I am centering a PopUp screen and add a few LabelFields which must be centered too. I put the position of the Popup manually, but the LabelFields aren't always align properly... What have I done wrong?

    The PopupScreen position which focuses more or less now:

    private final static int _X = (Display.getWidth() - 510);
    private final static int _Y = (Display.getHeight() - _Height) >> 1;
    
    public void sublayout(int width, int height) {
            super.sublayout(getPreferredWidth(), Integer.MAX_VALUE);
            setExtent(getPreferredWidth(), getPreferredHeight());
            setPosition(_X, _Y);
        }
    

    These are the LabelFields thereon that are even more on the left side:

    LabelField title = new LabelField("UI Test App",
                    Field.FIELD_HCENTER);
    LabelField version = new LabelField("Version X.Y",
                    LabelField.FIELD_HCENTER);
    
    add(title);
    add(version);
    

    "It seems that the separatorField has a standard in a popup length if you don't customize it?

    Sort of.  In fact, the SeparatorField wants to put in a separator that is as wide as Manager it is in. so, indeed, it will force the Manager to use the full width that it is given.

    One way round this is to limit width is given by the Manager. Here's some code to show how do.  See screen capture for the result.

       public InfoScreen() {
            super(new VerticalFieldManager() {
                public void sublayout(int width, int height) {
                    super.sublayout(Math.min(width, Display.getWidth()/2), height);
                }
            });
            LabelField title = new LabelField("UI Test App", Field.FIELD_HCENTER);
            LabelField version = new LabelField("Version X.Y",
                    LabelField.FIELD_HCENTER);
            ButtonField closeBtn = new ButtonField("Close", ButtonField.FIELD_HCENTER);
            add(title);
            add(version);
            add(new SeparatorField());
            add(closeBtn);
        }
    

    There are other options, for example, you can use the page layout in the SeparatorField to restruct its width.  Then the Director would not forced to use any of its width by the SeparatorField.  The best option will depend on exactly what you are trying to reach and what other restrictions you have.

Maybe you are looking for

  • Do we need to disable Javascript in Firefox / Options / content box? Or just in the Java Control Panel?

    Need clarification on issues of Java. It is clear that we can disable Java in the configuration java itself or via the plug-in Panel. However, what about the firefox options menu? When you click on Tools_Options_Content and then you can check or unch

  • What is the best program of security for iMac and I have pad pro

    What is the best program for internet security for iMac I heard bad things about norton and McAfee to consider. But I read that apple computers are fix any help please

  • I SOLVED MY PROBLEM OF UPDATE

    After several weeks and a little help from MS, I can now updates to d/l win7 and I want to share my solution. I have win 7, 64 bit and had not been able to d/l since Sept/2010 approximately. I have ex-athletes I had deleted the free Avira antivirus p

  • I can't connect to MSN, NEED of HELP PLEASE!

    I can't connect to MSN, it tells me that I must be upgraded. When I klick 'Yes', then it starts searching for updates but can find no updates. When I try to log on again then it is same thing. When I klick 'No' then it is not log. What should I do? I

  • check registartion early? best way to implement

    Hey guys,. I tried to determine the best way to make my request to verify a valid registration on startup key and if the key is valid, the tracks of the app.  If the key is not there, or invalid, it has a pop up screen to enter a registration code.