FieldListener... LabelField

I have a screen with a 'labelfield' initially set to "0000", .i have stated this labelfield in "public class ContactsManagerScreen extends screen '... I have a FiledListener class inside the class of ContactsManagerScreen,... now, this listener responds to a click of a button... When control is handed to this FieldListener... via clicking on a button... I want the text of the LabelField to change the "0000" to "1234"... can anyone please help me on how to reach the LabelField text within the FieldListener class.

I finally thought to her, I had to extend my class in the FieldListener and then implement FieldChangeListener... * all smiles *.

Tags: BlackBerry Developers

Similar Questions

  • 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.

  • Width LabelField

    How can I set the default width of a LabelField.  Currently if I draw a border around each LabelField with one character in each box, the field that holds a 'I' is narrower than a field that contains a 'W '.  How can I do to make each LabelField has the same width?

    Thank you!

    LabelField _buttonfield_highscore = newLabelField ("Hello") {public int getPreferredWidth() {return 200 ;} protected Sub layout (int maxWidth, maxHeight int) {super.layout (getPreferredWidth(), maxHeight) ;}};}}}

  • problem adding multiple LabelField...

    Hello

    I can think of 3-way and only 1) works, 2) and (3) do not display anything. Why? I bet my allocation of memory is incorrect, the return of my function is probably the address, but what do I do?

    Solution 1) is clearly not my first choice...

    Thank you.

    1)

    LabelField string1 = new LabelField ("test1");
    Add (string1);
    LabelField string2 = new LabelField ("test2");
    Add (string2);

    2)

    private class MyScreen extends screen
    {

    ....

    private LabelField testLabel [= new LabelField [100];]

    .....

    for (int i = 0; i)<=numEvents;>
    {outTextStep (i, testLabel [i]);
    Add (testLabel [i]);
    }

    private void outTextStep (int i, LabelField newField)
    {
    newField = new LabelField ("test");
    }

    3)

    private class MyScreen extends screen
    {

    ....

    private LabelField testLabel [= new LabelField [100];]

    .....

    for (int i = 0; i)<=numEvents;>
    {add (outTextStep (i));
    }

    private outTextStep (int i) LabelField
    {
    LabelField string1 = new LabelField ("test");
    return string1;
    }

    I guess that RexDoug meant:

    return new LabelField ("test:" + Integer.toString (i));

    Can't see anything obviously wrong with your code, but we do not know if the lops are executed, or what is the value of numEvents.  I put just a breakpoint on your for loops, check to see if it is actually called and what is the value of numEvents.  Who should settle where the problem is quite quickly.

Maybe you are looking for

  • Satellite Pro A10 - unable to connect to the internet

    I have an old Satellite SPA10 who lost the internet connection a year ago.The components in question are:Ethernet controllerNetwork controllerVideo controllerVideo controller (VGA)I tried many attempts to install drivers to replace those already on,

  • Reading of temperatures using PXI-4351

    I can't configure my PXI-4351.  I can't read a measure of a thermocouple unless I run NI MAX Test Panel for the temperature at the same time as I run my Labview code.  If I open the test panel and configured to read a thermocouple, my labview code wi

  • Addition of Service Pack 3 for Windows XP Home Edition creates the system failure

    We have an older Compaq Presario that came with Windows XP Home Edition. [a Pentium 1 2005]I try to install Windows Live Onecare (free Qwest).  When I update our Windows XP Home with Service Pack 3, when I reboot I get a black screen that says that t

  • Setup did not find any hard drives installed on your computer.

    Make sure that the hard drives are powered on and well connegted to your computer. And that any hardware configuration of the drives is correct. This may involve running a program diagnosis provided by the manufacturer. How do the hard disk driver. s

  • Get Windows 7 from one computer to the other.

    I installed and activated a new copy ot 8 windows on a new computer, I built for the games, but W8 wouldn't some of the games.  The same games work well with windows 7.  Can I remove the installation of Windows 8 and install windows 7 in "swopper" on