BasicEditField.getText is

I'm really trying to get the hang of this... I really struggled with what is probably very basic.  Look at the code below... my Dialog.alert never fires and I can't understand why.  Any suggestions?

privateBasicEditField identifierfield = null;
public void fieldChanged(Field f, int context)
    {

        ButtonField button = (ButtonField) f;
         identifierfield.setText(identifierfield.getText() + button.getLabel());
                if ( identifierfield.getText() == "confusion")
                {
                    Dialog.alert("Awesome");
                }

                return;
      }

Thanks much for any help!

You have a semicolon in the wrong place.

I think that there are a couple of other minor problems, but here is a rewritten code (not tested), which should clarify the points for you:

public void fieldChanged(Field f, int context) {
    ButtonField button = (ButtonField) f;
    String newString = identifierfield.getText() + button.getLabel();
    identifierfield.setText(newString);
    if ( newString.equals("confusion") ) {
        Dialog.alert("Awesome");
    }
    return;
}

Tags: BlackBerry Developers

Similar Questions

  • Problem with maintaining the original text of basiceditfield even on unfocus after typing the text.

    I have a Basiceditfield with the original text. Here is the code:

    searchField = new EditField ("","", 1024, EditField.FILTER_DEFAULT | ") EditField.NO_NEWLINE)
    {
    protected void onFocus (int direction)
    {
    setLabel("");
    This.Invalidate ();
    };
    protected void onUnfocus()
    {
    setLabel ("Search");
    This.Invalidate ();
    };
    };
    searchField.setLabel ("Search");

    Text initially searchfield is "search". Onfocus his game to «» I type something in the searchfield, assumes that "ab". When the focus is removed from searchfield label has the value "Searchab". while I want to as "search". Help, please.

    on the focus, use getText, check if it is 'Search', setText to «»
    about onfocus, use getText, check whether it is "", set it to "search".
    on keyChar, use getText, check if "search, use setText for" ", and then return super.»

  • Why the setFocus() and setText() methods does not work for BasicEditField

    Hello

    I tried to apply the methods of setFocus() and setText() on a BasicEditField, but he always up "illegal state exception.   However, the getText() method can work.

    Can someone explain this please? Thank you!

    Another thing would be - if you use filters on your EditField and allows you to define something that is not allowed by the filter, it will throw an exception setText()...

  • Delimit by BasicEditField with media

    I have a BasicEditField that contains the area code of a telephone number and want the text in square brackets. So that the user sees "enter the area code: (_) ' where they can enter their area code in this space.

    I know a way to do so would make a horizontal on the back field Manager ")", but thought that someone would know a better way to do it. Any thoughts?

    I finally understand - thought I'd share in case - that someone has had the same question: (do not forget that you add to the field, so when you use the data you lop this additional support.)

    areaCode1Field = new BasicEditField("Area Code: (", "", 20, Field.EDITABLE)
                    {
                        //Add on the other bracket
                        public void onUnfocus()
                        {
                            if (this.getTextLength() ==3)
                            {
                                this.setText(this.getText() + ")");
                            }
                            super.onUnfocus();
                            this.invalidate();
                        }
                    };
    
  • Capture the Keycodes / keyDown in BasicEditField with digital filter

    I tried to understand cela other posts and the API, but I can't seem to get it.

    I created a BasicEditField and applied a filter TextFilter so that it can accept only digital entries. It is the substitution of the event keyDown as expected, but I can not just to capture "1,2,3,4,5,6,7,8,9,0" - he used ' enter my conditional statements - which of course means that the controls do not work.

    I tried the keycodes of compairing the raw numbers, converted characters, KEY_NUM2 and basically everything that was suggested, but I'm obviously missing something.

       BasicEditField numEnter = new BasicEditField()    {     protected boolean keyDown(int keycode, int time)      {             int key = Keypad.key(keycode);                //char key = (char) Keypad.key(keycode);              //this.setText(Integer.toString(key));
    
              //if (key == Characters.DIGIT_ONE)            //if (keycode == 570163217)               if (key == 01)                {                                 this.setText("ONE");              }             else if (keycode == 45219842)             {                                 this.setText("TWO");              }
    
              return false;     } };
    
      // set the filter numEnter.setFilter(TextFilter.get(TextFilter.NUMERIC));
    
     // add to field manager   hfm_logo.add(numEnter);
    

    As always, your help is always appreciated.

    Well...

    It is the solution that I came. Don't know if it's fair, but it seems to work.

    Basically, with the NumericFilter codes keyboard is the same as if you have the filter applied or not to the text box, so even if you override the keydown it doesn't matter if you're trying to intercept him because he gives you the key you pressed on, not what appear after the filter.

    That being said, if you try to do this in the keyDown as you cannot capture because the character needs to be painted on the screen first, otherwise you get an error happens nowhere. So if you paint the screen first and then take some text is located in the numEnter, then put it to white even once, you can capture the NUMBERS that are entered (forcably) on each keyboard phone.

    Tested with:

    9000

    8110

    8820

    8800

    8300

    Should work with anything 4.2.0 + JDE

     EditField numEnter = new EditField()
        {
    
            protected void paint(Graphics graphics)
            {
                super.paint(graphics);
    
                if (this.getText().length() > 0)
                {
                    switch (this.getText().charAt(0))
                    {
                    case Characters.DIGIT_ONE:
                        text.setText("DIGIT_ONE");
                        break;
                    case Characters.DIGIT_TWO:
                        text.setText("DIGIT_TWO");
                        break;
                    case Characters.DIGIT_THREE:
                        text.setText("DIGIT_THREE");
                        break;
                    case Characters.DIGIT_FOUR:
                        text.setText("DIGIT_FOUR");
                        break;
                    case Characters.DIGIT_FIVE:
                        text.setText("DIGIT_FIVE");
                        break;
                    case Characters.DIGIT_SIX:
                        text.setText("DIGIT_SIX");
                        break;
                    case Characters.DIGIT_SEVEN:
                        text.setText("DIGIT_SEVEN");
                        break;
                    case Characters.DIGIT_EIGHT:
                        text.setText("DIGIT_EIGHT");
                        break;
                    case Characters.DIGIT_NINE:
                        text.setText("DIGIT_NINE");
                        break;
                    case Characters.DIGIT_ZERO:
                        text.setText("DIGIT_ZERO");
                        break;
                    }
    
                    this.setText("");
                }
            }
        };
    
  • How to USE the information the user entered via BasicEditField or AutoTextEditField

    What BlackBerry watch document - step by step - how to extract the data that the user has typed on the screen using BasicEditField or AutoTextEditField. and use it in a Java program? If BB doesn't have a good document, here are all the samples you have found useful?

    I'm sorry, I didn't know that you had already gone through everything that is available.  And Yes, I was aware that the tutorials do not directly provide your requirement. I find that frequently samples and/or the provided code do not directly correspond to my needs and I therefore extend, it goes with the territory of being a programmer and is actually the part that I love - copy the code isn't fun and does not help his understanding.  Maybe you don't find so much fun.  Instead, please enjoy the following example.

    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.component.BasicEditField;
    import net.rim.device.api.ui.container.MainScreen;
    
    public final class AddDemo extends UiApplication {
    
        public static void main(String[] args) {
                AddDemo theApp = new AddDemo();
                theApp.enterEventDispatcher();
        }
    
        public AddDemo() {   
    
            MainScreen mainScreen = new AddScreen();
            pushScreen(mainScreen);
        }
    }
    
    class AddScreen extends MainScreen
                    implements FieldChangeListener {
    
        BasicEditField _firstField = new BasicEditField("First Operand: ", "0", 10, BasicEditField.FILTER_INTEGER);
        BasicEditField _secField = new BasicEditField("Second Operand: ", "0", 10, BasicEditField.FILTER_INTEGER);
        BasicEditField _resultField = new BasicEditField("Result: ", "0", 11, BasicEditField.NON_FOCUSABLE);
    
        public AddScreen() {
            super();
            this.add(_firstField);
            _firstField.setChangeListener(this);
            this.add(_secField);
            _secField.setChangeListener(this);
            this.add(_resultField);
        }
    
        public void fieldChanged(Field field, int context) {
            String firstFieldData = _firstField.getText();
            int firstValue = 0;
            if ( firstFieldData != null && firstFieldData.length() > 0 ) {
                firstValue = Integer.parseInt(firstFieldData);
            }
            String secFieldData = _secField.getText();
            int secondValue = 0;
            if ( secFieldData != null && secFieldData.length() > 0 ) {
                secondValue = Integer.parseInt(secFieldData);
            }
            _resultField.setText(Integer.toString(firstValue + secondValue));
        }
    
    }
    
  • right-aligned a BasicEditField within the screen

    Hello

    How do your right justify a BasicEditField in a screen?

    If you do the following, framed in any case left field shows:

    Processes = new BasicEditField ("process", 7, Field.FIELD_RIGHT);
    This.Add (processes);

    If you create a LabelField, you can right-aligned it on the screen with this:

    This.Add (new LabelField ("Login al sistema", LabelField.FIELD_RIGHT));

    TKS.

    I wrote my own...

    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.FieldChangeListener;
    import net.rim.device.api.ui.component.EditField;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.HorizontalFieldManager;
    
    public class JustifiedEditField extends HorizontalFieldManager implements FieldChangeListener {
    
        LabelField lf;
        EditField ef;
        int dw = Display.getWidth();
        int rightMargin;
    
        public JustifiedEditField(String label, String value, int maxChars, long style) {
            super(USE_ALL_WIDTH);
            ef = new EditField(null, value, maxChars, style) {
                protected void onDisplay() {
                    update(0);
                }
    
                protected void update(int d) {
                    super.update(d);
                    int efw = getFont().getAdvance(super.getText());
                    setPosition(dw - efw - rightMargin, 0);
                }
            };
            ef.setChangeListener(this);
            lf = new LabelField(label);
            add(lf);
            add(ef);
        }
    
        public LabelField getLabelField() {
            return lf;
        }
    
        public EditField getEditField() {
            return ef;
        }
    
        public String getText() {
            return ef.getText();
        }
    
        public void setRightMargin(int m) {
            rightMargin = m;
        }
    
        public int getRightMargin() {
            return rightMargin;
        }
    
        public void fieldChanged(Field field, int context) {
            invalidate();
        }
    
    }
    
  • The procedure entry point?getText@FxtField@@QBE? AVFXWString@@XZ could not be located in the dynamic linklibrary fox.dll

    I get the error message "the procedure point?getText@FxtField@@QBE entry? "AVFXWString@@XZ could not be located in the dynamic linklibrary fox.dll ' when I boot.  How should I do?

    Looks like it has something to do with the Acronis software, there is an old post here: -.

    http://Forum.Acronis.com/Forum/6553

    If it is of no use and that you use the disk imaging software and then uninstall it or go to start/run type msconfig press enter and edit startup.

  • Store a copy in a BasicEditField

    Try to keep a double in a BasicEditField or similar (RichTextField, Etc) but I don't have the option for 'setValue', only setText.

    When I try to setText():

    It gives the error ' the setText (String) of the method in the BasicEditField type is not applicable for the arguments (Double). "

    Ideas?

    paymentField.setText(new Double(payment));
    

    Convert double to a string.

    paymentField.setText (Double.toString (payment))

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

  • BasicEditField: set the Focus

    Hello

    If I do not substitute the field basicEdit layout() method, it takes the entire screen width.

    The following code creates an EditField, but I can't focus on that, everything I type I am not either.

    I tried to overridding method object. It still does not.

    Please guide me.

    Background = BackgroundFactory.createSolidBackground (Color.WHITE);
            
    statusMsgFieldEdit = new BasicEditField ("", statusMsg, 140, FOCUSABLE) {}
    Protected Sub layout (int width, int height) {}
    width = 200;
    height = 40;
    setExtent (width, height);
    }

    public int getPreferredHeight() {}
    Return to 40;
    }

    public int getPreferredWidth() {}
    Return Display.getWidth ();
    }
    };
    statusMsgFieldEdit.setBackground (background);

    The other thing is that you must tell the EditField what are its limits, so that it can adjust its alignment won.  So instead of:

    Protected Sub layout (int width, int height) {}
    width = 200;
    height = 40;
    setExtent (width, height);
    }

    You should really do

    Protected Sub layout (int width, int height) {}
    width = 200;
    height = 40;
    Super.Layout (width, height);
    }

  • Focus BasicEditField and buttons problem

    Objective:

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

    To develop Blackberry app without sequence of focus problem when using the BB with trackpad

    The problem:

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

    I have 5 BasicEditFields and 5 buttons. All objects are aligned vertically. When I move the finger on the trackpad, update doesn't move from one BasicEditField to another, some are fried, and this happens also with buttons, for example, when the focus is on the first button in the row, and then for some reason when I move the finger on the trackpad button next emphasis is not the one below , but attention "jumps" to the last button. Is possible to set 'order of sequence focus' or something like that?

    If you have Blacberry with touchscreen is not a problem, but if develop you some app for example BB Curve 9360 which has only trackpad, so you cannot select all items.

    Software used:

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

    Eclipse SDK Indigo version 3.7.2.

    BlackBerry Java plug-in 1.5.0.201112201607

    Operating system:

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

    Win7 64 bit

    Well, I have the solution

    Don't know why it works, but it does.

    I did two things:

    1.)

    I replaced .add with insert and then add Index numbers

    2.)

    This added to the code:

    protected boolean navigationMovement (int dx, int dy, int, int time status) {}
    Returns false;
    }

    I tried without step 2). but then focus jump bad, in any case, it now works as it should.

    Thank you all for your time and your suggestions.

  • Calculation of the minimum required size for a BasicEditField

    Hello

    I hope someone can help! This is continued in another post, I had about resize a BasicEditField so I could put a button on the same line.

    I re-size my BasicEditField to be half the width of the screen. I also set the maximum number of characters which they reached 6. When the user tries to enter the character 7 I get an alert that the field is full. I have a border around the BasicEditField and the user, it seems they should be able to enter more characters that is to say the space to enter the number is much larger than 6 characters.

    Does anyone know a way to calculate the size so the domain will be the right size it of to say to fit to the label and up to 6 characters, but not bigger?

    I hope I've explained this well enough to understand. Thanks in advance for any help

    Just put a code here:

    http://supportforums.BlackBerry.com/T5/Java-development/please-help-with-trying-to-put-a-BasicEditFi...

  • Blocking of the press 'Enter' in BasicEditField

    Hello

    I want to restrict the key 'Enter' in the field of basic edition...

    I mean he should alow that one line...

    How do I...?

    Alternatively, you can try to set the style, for example:

    BasicEditField bef = new BasicEditField (BasicEditField.NO_NEWLINE);

  • Matter of style BasicEditField

    Hi all

    IM using BasicEditField that I need to enter the characters in all CAPITALS, so I used the "BasicEditField.FILTER_UPPERCASE" style, when I did I was able to enter the uppercase characters, but I'm not able to enter the SPACE.  I travel in Virtual_KEY_BOARD in the space key is disabled.

    Same BasicEditField.FILTER_UPPERCASE | "BasicEditField.FILTER_DEFAULT" is also down. So how to get there, one guide me.

    Thanks in advance

    Anil

    This give a try.

    UppercaseTextFilter uptf = new UppercaseTextFilter() {}
    public char convert (character char, int status) {}
    If (character == Characters.SPACE) {}
    Returns the character;
    }
    Return super.convert (character, status);
    }
    public boolean validate (char character) {}
    If (character == Characters.SPACE) {}
    Returns true;
    }
    Return super.validate (character);
    }
    };
    BasicEditField bef = new BasicEditField ("upper Test:", null);

    I think bef attributes appropriate for you.

Maybe you are looking for

  • Satellite L500 - wireless network adapter is missing in Device Manager

    Hi guys, I have read a lot of discussion but not found a job of answer to my problem and yet, although this doesn't seem to be a common problem, so I was wondering if someone can help out me. Model laptop is L500-1VT. There is no switch on / off exte

  • Envy 14-2095en: drivers envy 14-2095en

    I need to reinstal driver integrated + dedicated graphics, but currently there is no place on hp.com where to find all the drivers for this product. Is - this temporary error or? Thanks for the reply

  • Help blackBerry Smartphones! No outgoing call...

    Hello I just got a new 9700 and when I'm composing it gives me me the following message. Call failed due to the error of control box SIM Toolkit. Please try again later. and then I get a second message- SIM: Call inadmissible. I tried to update its v

  • ColdFusion Enterprise for non-production server license

    Currently we have 1 production server and 3 servers out of production (a disaster recovery server, an internal test server and an external test for penetration testing server).With CF10 Enterprise license, allow us to use the same server license of p

  • In bulk changes to metadata?

    I bought a used camera and took hundreds of photos before I realized that the previous owner had put copyright on the camera information.  All the photos I have in LR now have his name as being the creator.  Is it possible to change the metadata of t