EditField problem!

Hi every1

I was faced with a problem when adding a text field on screen.

When I'm trying to add a field for a GridFieldmanager editing, I m getting an EXCEPTION 'ILLEGALARGUMENT' and ending of app.

Here I m using the object persistent 2 store text in of editfield

Infact I m error, when I m 2 access the same screen twice, by train, but not in the first attempt. Initially I m 2 can access screen with success, but in my second attempt I m get error at the particular point dat dat

Help me... Urgent!

Concerning

Kiran

http://www.BlackBerry.com/developers/docs/6.0.0api/NET/rim/device/API/UI/component/BasicEditField.ht...

Throws:
IllegalArgumentException - if the text cannot be entered in an edit field.

My guess would be that you have a filter set on the field and try to define a text that is in conflict with it, but without more information, it is difficult to say.

Tags: BlackBerry Developers

Similar Questions

  • Problem with EditField?

    Hello

    I created an EditField and iam trying to make a rectangular shape of it, but the problem is while typing cursor comes from new line and it increases the width of the textfield.  Please find the picture below.  I expect that letters should be on the left is not down. For example, in the browser of the Simulator, there are a TextBox it behave like that.  I added the rectangle to textfiled I think it takes the screen.  Please provide a useful for the same code snippet.  Thanks advanced

    edit = new EditField("", "",50, EditField.FILTER_DEFAULT | EditField.NO_NEWLINE)
            {
                protected void layout(int maxWidth, int maxHeight) {
                    super.layout(137, this.getHeight());
                    setExtent(137, this.getHeight());
                }
                public void paint( Graphics graphics ) {
                    graphics.setColor(Color.RED);
                    System.out.println("!!!!!!!!!!!!!!!!!Width :: "+getWidth());
                                    graphics.setColor(Color.BLACK);
                    super.paint(graphics);
                }
            };
    

    With the recent restructuring of the site web, Rim have moved the magazines.  Try here:

    http://NA.BlackBerry.com/eng/devjournals/resources/journals/jul_2005/creating_textbox_field.jsp

  • problem of return back in EditField

    Hello

    I have an EditField. When I run an editfield.backspace (1) when the cursor position is 1, I get an IndexOutofBounds exception.

    Any ideas on how to solve this problem?

    Thank you

    Hi, please tell me your requirement in terms of what you want to do?, I understand your code, but just tell me what is the feature.

  • Bimap field + EditField click problem

    Hello

    In my application, I am increasing and decreasing value in an editfield using two buttonfields, everything works fine, but if I click on the changed value in the editifeld picture but menu "Application report" come again by pressing ESC and then only I am able to click on the image.

    Even if I click editfield also 'switch' application menu pop up appears please check the picture of the call and inform me how to limit this menu in the click bimap and editfield

    Note: earlier in the popup 'application Switch, close' options appear in the context menu, but after using the below only switch application code comes

    protected void makeMenu (menu Menu, for example int)
    {
    menu.deleteAll ();
    }

    If you return false, you indicate that you have not consumed the event (and a few other layer will be, so the menu).
    return true instead.

  • EditField setText problem...

    Hi everyone out there.

    I have a textField in which I enter the text

    I added a listener to this text field

    hwen I entered text in the text box for each two characters that I need to store the characters and I need to replace the text with ".". (once the dowry for a character)...

    is it possible to do...

    Here is the code how I did it...

    but I know where I am doing wrong...

    but I don't get how to solve this...

    edit.setChangeListener (new FieldChangeListener() {}

    ' Public Sub fieldChanged (field field, int context) {}

    int length = edit.getTextLength ();
    If (length! = 0) {}
    String [];

    If (length % 2 == 0) {}
    int size;
    If (length / 2 == 0) {}
    size = 1;
    } else
    size = length / 2;
    String = new String [size];
    int j = charIndex;
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i)< size;="" i++)="">
    If (Edit.GetText (j, 2)! = null)
    String [i] = edit.getText (d, 2);
    for (int y = 0; y)<>
    buffer. Append(".");
    vertical.deleteAll ();
    vertical. Add (new LabelField (string [i]));
    vertical. Add (new LabelField (buffer.toString ()));
    j = j + 2;

    edit.setText (buffer.toString ());    When this line is running the listener calls once again
    }

    }

    } else
    vertical.deleteAll ();
    }

    });

    Hey Hey...

    I did it with her...

    Thank you all...

  • EditField: protected boolean insert (...) not called if the device uses VirtualKeyboard

    Hi all

    I extend the EditField class to intercept the entries of tank / backspaces and do something. I would outweigh all the methods of the superclass:

    protected boolean insert(char arg0, int arg1);
    public int insert(String text);
    protected int insert(String text, int context);
    
    protected boolean backspace();
    protected int backspace(int count, int context);
    public int backspace(int count);
    

    I tried on a 8520 (which has a physical keyboard) and the methods overridden were correctly when you type something in the field. However, this is not the case on a touch device (tried on a 9380). In this case the text is typed and showed correctly in the EditField custom, but not the method above is called never. I am quite confused...

    Is anyone of you know how to insert text in the virtual keyboard in the EditField? Is it possible to intercept these events?

    See you soon,.

    Beto

    The problem with keyChar and keyDown is that the char to insert depends on the keyboard layout, I didn't want to do something that it is already done by RIM.

    However, I have tried those overring however, but keyChar is never invoked, and keyDown gave place to a chariot double inserted in the editfield...

    In the end, I followed a suggestion made by @peter_strange in another post (I'll add the link if I managed to find it again) and put a FieldChangeListener on the edit field. When field changes, if the context is 0 (user action), I check if the text is changed and do what I have to do...

    Thank you.

    Beto

  • ALT + 2 or shift + 2 is not functional in Android EditField

    How do Alt + 2 OR shift + 2 functional in Android EditField component which Alt + 0-9 & SHIFT + 0 to 9 are respectively seized from 0 to 9. Only Alt + 2 & shift + 2 aren't seizes 2 in the EditField on all physical BlackBerry QWERTY devices such as the Q5, Q10, passport, P 9983 & classic.

    Is this a known issue? This hotfix is scheduled to be delivered in the future BlackBerry Runtime for Android update applications?

    This problem seems to occur when the inputType is set to 'numberPassword '. A bug report has been noted so I hope that the issue will be resolved in the future.

    Remove inputType = "numberPassword" will allow you to use the shortcut Alt + e to enter '2', but I guess you want to restrict the EditText to accept only numeric characters.

    At the same time (if you still want to accept numeric characters), do not hold down the shift or Alt to enter '2' with inputType = "numberPassword." You can simply press the 'e' '2 '.

  • Display problem on 8310 and 8330

    Hello Experts,

    I have a blackberry app that works very well in all devices except 8310 and 8330.

    My application appears a screen (which has a LabelField and a BasicEditField) when a button is clicked. It works in all devices, but on the other hand, does not show 8310 and 8330 upward the LabelField and BasicEditField, it shows me just a white screen. But when I press 'Enter' on the blank screen, it triggers the LabelField FieldChanged event. How is it possible?

    May be that the two fields are hidden?

    If so, is to show all devices.

    I'm so confused.

    Please advice me on this.

    Thank you!!!

    I solved this problem by simply moving

    this.setFont (defaultFont);

    of the getPreferredWidth method to the constructor of the an EditField subclass.

    But I do not know the reasson for why it happens?

    Thank you for all.

  • Custome Field took a nullpointexception in the labefiled and 7.1 paint method only you have this problem! Pls help me?

    KIM I create a custom entry field as below:

    public class AddEditField extends HorizontalFieldManager {
        private LabelField labelField;
        private EditField contentField;
        private RichTextField wrapaddField;
        HorizontalFieldManager textMgr;
        HorizontalFieldManager wrapMgr;
        private static final int HPADDING = Display.getWidth() <= 320 ? 6 : 8;
        Font font;
    
        public AddEditField(String label, Font font, int maxSpace) {
            this(label, 0, font, maxSpace);
        }
    
        public AddEditField(String label, long style, Font cfont, int maxSpace) {
            super(NO_HORIZONTAL_SCROLL);
            this.font = cfont;
            textMgr = new HorizontalFieldManager(HORIZONTAL_SCROLL | FIELD_VCENTER);
            wrapMgr = new HorizontalFieldManager(FIELD_VCENTER);
            wrapaddField = new RichTextField(RichTextField.TEXT_ALIGN_LEFT);
            long cstyle = 0;
            if (style == 0) {
                cstyle = EditField.NO_NEWLINE | EditField.FOCUSABLE
                        | EditField.EDITABLE | FIELD_VCENTER;
            } else {
                cstyle = EditField.NO_NEWLINE | EditField.FOCUSABLE
                        | EditField.EDITABLE | style | FIELD_VCENTER;
            }
            contentField = new EditField(cstyle) {
                protected void paint(Graphics graphics) {
    
                    // Font font = getFont().derive(Font.PLAIN, fontSize);
                    graphics.setFont(font);
                    graphics.setColor(0x666666);
                    super.paint(graphics);
                }
    
                protected void onFocus(int direction) {
                    super.onFocus(direction);
                    invalidate();
                }
    
                protected void onUnfocus() {
                    super.onUnfocus();
                    // if (VirtualKeyboard.isSupported()) {
                    // VirtualKeyboard vKeyboard =getVirtualKeyboard();
                    // vKeyboard.setVisibility(VirtualKeyboard.HIDE);
                    // }
    
                }
            };
            labelField = new LabelField(label, FIELD_LEFT | FIELD_VCENTER) {
                protected void paint(Graphics graphics) {
                    graphics.setColor(0x006699);
                    graphics.setFont(font);
                    super.paint(graphics);
                }
            };
            LabelField spaceF = new LabelField() {
    
                protected void layout(int width, int height) {
                    // TODO Auto-generated method stub
                    //super.layout(HPADDING, font.getHeight() + 10);
                    setExtent(HPADDING, font.getHeight() + 10);
                }
            };
            add(spaceF);
            add(labelField);
            final int space = maxSpace - font.getAdvance(labelField.getText());
            LabelField spaceF2 = new LabelField() {
    
                protected void layout(int width, int height) {
                    // TODO Auto-generated method stub
                    // super.layout(space, font.getHeight() + 10);
                    setExtent(space, font.getHeight() + 10);
                }
            };
            add(spaceF2);
            textMgr.add(contentField);
            wrapMgr.add(wrapaddField);
            add(textMgr);
        }
    
        public String getText() {
            return contentField.getText();
        }
    
        public void setText(String text) {
            synchronized (UiApplication.getEventLock()) {
                wrapaddField.setText(text);
                contentField.setText(text);
            }
        }
    
        public void setEditMode(boolean editable) {
            String text = wrapaddField.getText();
            synchronized (UiApplication.getEventLock()) {
                if (editable) {
                    contentField.setText(text);
                    if (wrapMgr.getManager() == this) {
                        delete(wrapMgr);
                    }
                    if (textMgr.getManager() != this) {
                        add(textMgr);
                    }
                } else {
                    if (textMgr.getManager() == this) {
                        delete(textMgr);
                    }
                    if (wrapMgr.getManager() != this) {
                        add(wrapMgr);
                    }
                }
            }
        }
    
    }
    

    Then I create: new AddEditField ("address:", cFont, maxSpace);  and add it to a screen.

    When I try to open this form. It is nullpointexception: the eclipse debugger show the info such as:

    AddEditField$ 4labelfield.paint line 385.

    Please help me to check the code. why it can run in 0 s 7.0 and before, only 7.1 has had this problem?

    Thank you

    Hi Flybrid,

    I checked at the time of your code,

    I am able to run your code by deleting page layout override methods in two fields of the label.

    The problem with the substitution of the method of layout in the spaceF and spaceF2 fields.

    But I can't explain why.

    I think that you can achieve the same thing by replacing getPrefferedWidth() and getPrefferedHeight() above the fields instead of page layout.

    Thank you.

  • Non editable field change to highlight the problem

    Hi all

    I have an edit non editable field in my screen. In order to make the difference between editable and non editable field, I put the bottom of the field cannot be changed to light gray as in the code below:

       Border nonEditableBorder=BorderFactory.createRoundedBorder(new XYEdges(5, 5, 5, 5),Color.LIGHTGRAY,Border.STYLE_FILLED|Border.STYLE_TRANSPARENT);
    EditField textField=new EditField(EditField.NO_NEWLINE|EditField.FOCUSABLE|DrawStyle.RIGHT);
    textField.setBorder(nonEditableBorder);
    

    Now the field cannot be changed when I scroll the wheel to the right or left the text gets highlighted in white as shown in the image below:

    I don't want the text to highlight. Can anyone help me please with this. Thanks in advance.

    Kind regards

    S.A.Norton Stanley

    Hello

    Thank you. Overridding method drawFocus() and nothing doing, emphasis has been disabled on the fields and the white highlight was not. But once I reached the first or the last field of the white selection screen gets drawn again.  But the border I also assign the background of the field edit as shown below, and this solved my problem.

    Background bgNonEditable = BackgroundFactory.createSolidBackground(Color.LIGHTGRAY);
    textField.setBackground(bgNonEditable);
    
  • Persistent Store problem, need your help! ~

    Forgive and I would like to make a short story.

    Days, I am according to the A13_Storing_Persistent_Data_V2 document and fantasize for only a class useful for my application, but I am failed completely, here is that the source code written in the document.

    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.util.*;
    import java.util.*; 
    
    public class MusicStores extends UiApplication { 
    
      private AutoTextEditField namefield;
      private AutoTextEditField addressfield;
      private EditField phonefield;
      private EditField specialtyfield;
      private static Vector _data;
      private static PersistentObject store; 
    
      public static void main(String[] args) {
        MusicStores app = new MusicStores();
        app.enterEventDispatcher();
      } 
    
      public MusicStores() {
        MainScreen mainScreen = new MainScreen();
        mainScreen.setTitle(new LabelField("Favourite Music Store"));
        namefield = new AutoTextEditField("Store Name: ", "");
        addressfield = new AutoTextEditField("Address: ", "");
        phonefield = new EditField("Phone Number: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_PHONE);
        specialtyfield = new EditField("Music Type: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_DEFAULT);
        mainScreen.add(namefield);
        mainScreen.add(addressfield);
        mainScreen.add(phonefield);
        mainScreen.add(specialtyfield);
        mainScreen.addMenuItem(saveItem);
        mainScreen.addMenuItem(getItem);
        pushScreen(mainScreen);
      } 
    
      private MenuItem saveItem = new MenuItem("Save", 110, 10) {
        public void run() {
          StoreInfo info = new StoreInfo();
          info.setElement(StoreInfo.NAME, namefield.getText());
          info.setElement(StoreInfo.ADDRESS, ddressfield.getText());
          info.setElement(StoreInfo.PHONE, phonefield.getText());
          info.setElement(StoreInfo.SPECIALTY, specialtyfield.getText());
          _data.addElement(info);
          synchronized (store) {
            store.setContents(_data);
            store.commit();
          }
          Dialog.inform("Success!");
          namefield.setText(null);
          addressfield.setText(null);
          phonefield.setText("");
          specialtyfield.setText("");
        }
      }; 
    
      private MenuItem getItem = new MenuItem("Get", 110, 11) {
        public void run() {
          synchronized (store) {
            _data = (Vector) store.getContents();
            if (!_data.isEmpty()) {
              StoreInfo info = (StoreInfo) _data.lastElement(); 
    
              namefield.setText(info.getElement(StoreInfo.NAME));
              addressfield.setText(info.getElement(StoreInfo.ADDRESS));
              phonefield.setText(info.getElement(StoreInfo.PHONE));
              specialtyfield.setText(info.getElement(StoreInfo.SPECIALTY));
            }
          }
        }
      }; 
    
      static {
        store = PersistentStore.getPersistentObject(0xdec6a67096f833cL);
        synchronized (store) {
          if (store.getContents() == null) {
            store.setContents(new Vector());
            store.commit();
          }
        }
        _data = new Vector();
        _data = (Vector) store.getContents();
      } 
    
      private static final class StoreInfo implements Persistable {
        private Vector _elements;
        public static final int NAME = 0;
        public static final int ADDRESS = 1;
        public static final int PHONE = 2;
        public static final int SPECIALTY = 3; 
    
        public StoreInfo() {
          _elements = new Vector(4);
          for (int i = 0; i < _elements.capacity(); ++i) {
            _elements.addElement(new String(""));
          }
        } 
    
        public String getElement(int id) {
          return (String) _elements.elementAt(id);
        } 
    
        public void setElement(int id, String value) {
          _elements.setElementAt(value, id);
        }
      }
    }
    

    I put this code into two parts, the first part to record the second part to get info and the info, and they use the same class of StoreInfo, here is the code of the first part.

    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.util.*;
    import java.util.*; 
    
    public class SaveMusicInfo extends UiApplication { 
    
      private AutoTextEditField namefield;
      private AutoTextEditField addressfield;
      private EditField phonefield;
      private EditField specialtyfield;
      private static Vector _data;
      private static PersistentObject store; 
    
      public static void main(String[] args) {
        SaveMusicInfo app = new SaveMusicInfo();
        app.enterEventDispatcher();
      } 
    
      public SaveMusicInfo() {
        MainScreen mainScreen = new MainScreen();
        mainScreen.setTitle(new LabelField("Favourite Music Store"));
        namefield = new AutoTextEditField("Store Name: ", "");
        addressfield = new AutoTextEditField("Address: ", "");
        phonefield = new EditField("Phone Number: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_PHONE);
        specialtyfield = new EditField("Music Type: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_DEFAULT);
        mainScreen.add(namefield);
        mainScreen.add(addressfield);
        mainScreen.add(phonefield);
        mainScreen.add(specialtyfield);
        mainScreen.addMenuItem(saveItem);
        mainScreen.addMenuItem(getItem);
        pushScreen(mainScreen);
      } 
    
      private MenuItem saveItem = new MenuItem("Save", 110, 10) {
        public void run() {
          StoreInfo info = new StoreInfo();
          info.setElement(StoreInfo.NAME, namefield.getText());
          info.setElement(StoreInfo.ADDRESS, ddressfield.getText());
          info.setElement(StoreInfo.PHONE, phonefield.getText());
          info.setElement(StoreInfo.SPECIALTY, specialtyfield.getText());
          _data.addElement(info);
          synchronized (store) {
            store.setContents(_data);
            store.commit();
          }
          Dialog.inform("Success!");
          namefield.setText(null);
          addressfield.setText(null);
          phonefield.setText("");
          specialtyfield.setText("");
        }
      }; 
    
      static {
        store = PersistentStore.getPersistentObject(0xdec6a67096f833cL);
        synchronized (store) {
          if (store.getContents() == null) {
            store.setContents(new Vector());
            store.commit();
          }
        }
        _data = new Vector();
        _data = (Vector) store.getContents();
      } 
    
      private static final class StoreInfo implements Persistable {
        private Vector _elements;
        public static final int NAME = 0;
        public static final int ADDRESS = 1;
        public static final int PHONE = 2;
        public static final int SPECIALTY = 3; 
    
        public StoreInfo() {
          _elements = new Vector(4);
          for (int i = 0; i < _elements.capacity(); ++i) {
            _elements.addElement(new String(""));
          }
        } 
    
        public String getElement(int id) {
          return (String) _elements.elementAt(id);
        } 
    
        public void setElement(int id, String value) {
          _elements.setElementAt(value, id);
        }
      }
    }
    

    Following is the code of the second part.

    import net.rim.device.api.ui.*;
    import net.rim.device.api.ui.component.*;
    import net.rim.device.api.ui.container.*;
    import net.rim.device.api.system.*;
    import net.rim.device.api.util.*;
    import java.util.*; 
    
    public class GetMusicInfo extends UiApplication { 
    
      private AutoTextEditField namefield;
      private AutoTextEditField addressfield;
      private EditField phonefield;
      private EditField specialtyfield;
      private static Vector _data;
      private static PersistentObject store; 
    
      public static void main(String[] args) {
        GetMusicInfo app = new GetMusicinfo();
        app.enterEventDispatcher();
      } 
    
      public GetMusicInfo() {
        MainScreen mainScreen = new MainScreen();
        mainScreen.setTitle(new LabelField("Favourite Music Store"));
        namefield = new AutoTextEditField("Store Name: ", "");
        addressfield = new AutoTextEditField("Address: ", "");
        phonefield = new EditField("Phone Number: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_PHONE);
        specialtyfield = new EditField("Music Type: ", "", Integer.MAX_VALUE, BasicEditField.FILTER_DEFAULT);
        mainScreen.add(namefield);
        mainScreen.add(addressfield);
        mainScreen.add(phonefield);
        mainScreen.add(specialtyfield);
        mainScreen.addMenuItem(saveItem);
        mainScreen.addMenuItem(getItem);
        pushScreen(mainScreen);
      } 
    
      private MenuItem getItem = new MenuItem("Get", 110, 11) {
        public void run() {
          synchronized (store) {
            _data = (Vector) store.getContents();
            if (!_data.isEmpty()) {
              StoreInfo info = (StoreInfo) _data.lastElement(); 
    
              namefield.setText(info.getElement(StoreInfo.NAME));
              addressfield.setText(info.getElement(StoreInfo.ADDRESS));
              phonefield.setText(info.getElement(StoreInfo.PHONE));
              specialtyfield.setText(info.getElement(StoreInfo.SPECIALTY));
            }
          }
        }
      }; 
    
      static {
        store = PersistentStore.getPersistentObject(0xdec6a67096f833cL);
        synchronized (store) {
          if (store.getContents() == null) {
            store.setContents(new Vector());
            store.commit();
          }
        }
        _data = new Vector();
        _data = (Vector) store.getContents();
      } 
    
      private static final class StoreInfo implements Persistable {
        private Vector _elements;
        public static final int NAME = 0;
        public static final int ADDRESS = 1;
        public static final int PHONE = 2;
        public static final int SPECIALTY = 3; 
    
        public StoreInfo() {
          _elements = new Vector(4);
          for (int i = 0; i < _elements.capacity(); ++i) {
            _elements.addElement(new String(""));
          }
        } 
    
        public String getElement(int id) {
          return (String) _elements.elementAt(id);
        } 
    
        public void setElement(int id, String value) {
          _elements.setElementAt(value, id);
        }
      }
    }
    

    I'm runing the Project One (first part) and record information to be stored, and then I WANT TO runing the project two (part two), but I received an error message telling me there are two same defined the class in the system, I try to change the class name of StoreInfo in two project, the last of error messge disappeared , instead of a CastClassException error, I am so sad...

    For a long time debugging I found some interesting things, look at the below codes to two projects, please read the name of the StoreInfor class, not StoreInfo.

     private MenuItem getItem = new MenuItem("Get", 110, 11) {
        public void run() {
          synchronized (store) {
            _data = (Vector) store.getContents();
            if (!_data.isEmpty()) {
              StoreInfor info = (StoreInfor) _data.lastElement();
            }
          }
        }
      };
    

    Now the _data class name is StoreInfo@xxxxxx (using _data.getClass () .getName ()) and class StoreInfo project two was renamed to StoreInfor, of course, I received a CastClassException error.

    I finished the story, and I need some guys to help solve this problem, tks a lot! ~

    Creating a descriptor application blackberry project and inside, choose library. Then, each project must refer to this library.

  • Border and background for EditField

    I want to create EditField rounded, white but I use jre 4.5 Blackberry so I can't use:

    myEditField..setBorder(BorderFactory.createRoundedBorder(new XYEdges(2, 2, 2, 2),  0x35586C, Border.STYLE_SOLID));
    

    Because doesn't have class BorderFactory or border.

    I tried to draw a rectangle inside the paint method:

    myEditField = new EditField(){
                public void paint(Graphics g) {
                    super.paint(g);
                    int prevColor = g.getColor();
                    g.setColor( 0xffffff);
                    g.fillRoundRect(0, 0, getWidth(), getHeight(), 10, 10);
                    g.setColor(prevColor);
                }
            };
    

    I look fine, but the problem is that text inserted inside the EditField cannot be seen...

    Call super.paint () after you make your bottom paint. You cover it up with the fillRoundRect. Alternatively, if you are wanting just a border, you can use drawRoundRect().

  • Button in the pop-up screen problem

    Hi all

    I did a pop-up screen in which there are two buttons and an EditField. Now, I am faced with very weird problem. First button that I added in my code doesnot seem to work. It doesnot clicking and the second button is working well, why is it so can any body help out me of this.

    I provided the code here: -.

    public class PinPopup extends PopupScreen{
    public static  EditField texts;
    static String _userName=null;
    
    PinPopup()
        {
        super(new HorizontalFieldManager());
        Font f = Font.getDefault().derive(Font.BOLD, 16);
        setFont(f);
        texts=new EditField("","",200,Field.EDITABLE);
    
        ButtonField sendButton = new ButtonField(" Send  "){
            protected boolean navigationClick(int status, int time) {
                   Dialog.inform("Send");
                return true;
                }
        };
    
        ButtonField cancelButton = new ButtonField("Cancel"){
             protected boolean navigationClick(int status, int time) {
                   Dialog.inform("Cancel");
                return true;
                }
        };
    
        VerticalFieldManager _fieldManagerContext = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH | VerticalFieldManager.USE_ALL_HEIGHT)
            {
    
                public void sublayout(int width,int height) {
                    //super.sublayout(width, height);
                    int xpos = 0;
                    int ypos = 0;
                    Field field = getField(0);
                    layoutChild(field, 280, 50);
                    setPositionChild(field, xpos, ypos);
                    Field field1 = getField(1);
                    layoutChild(field1, 280, 50);
                    setPositionChild(field1, xpos+20, ypos+80);
                    Field field2 = getField(2);
                    layoutChild(field2, 280, 50);
                    setPositionChild(field2, xpos+145, ypos+80);
                    setPosition(150, 220);
                    setExtent(300, 220); 
    
                   }
                    public void paint(Graphics graphics)
                    {
                        //graphics.setColor(Color.WHITE);
                        Font f = Font.getDefault().derive(Font.BOLD, 16);
                        graphics.setFont(f);
                        graphics.drawText("SEND PIN",90, 20,0,200);
                        graphics.drawText( _userName,110,40,0,200);
                        graphics.setColor(Color.WHITE);
                        super.paint(graphics);
                    }
    
            }; 
    
                  _fieldManagerContext.add(texts);
                  _fieldManagerContext.add(cancelButton);
                  _fieldManagerContext.add(sendButton);
                  add(_fieldManagerContext);
    
        }
    
    }
    

    Hi Please help me in this

    Thanks in advance

    Why do you not use Horizontalfieldmanager for horizontal alignment.

    This is the code and it works fine.

    package com.winit.mobiads.ui.screens;

    Import net.rim.device.api.ui.Color;
    Import net.rim.device.api.ui.Field;
    Import net.rim.device.api.ui.Font;
    Import net.rim.device.api.ui.Graphics;
    Import net.rim.device.api.ui.component.ButtonField;
    Import net.rim.device.api.ui.component.Dialog;
    Import net.rim.device.api.ui.component.EditField;
    Import net.rim.device.api.ui.container.HorizontalFieldManager;
    Import net.rim.device.api.ui.container.PopupScreen;

    SerializableAttribute public class PinPopup extends PopupScreen {}
    public static EditField texts;
    public static String _userName = null;

    PinPopup()
    {
    Super (new HorizontalFieldManager());
    Police f = Font.getDefault () .derive (Font.BOLD, 16);
    setFont (f);
    texts = new EditField("","",200,Field.EDITABLE);
           
    ButtonField sendButton = new ButtonField ("send") {}
    protected boolean navigationClick (int status, int time) {}
    Dialog.Inform ("Send");
    Returns true;
    }
    };
         
    ButtonField cancelButton = new ButtonField ("Cancel") {}
    protected boolean navigationClick (int status, int time) {}
    Dialog.Inform ("Cancel");
    Returns true;
    }
    };

    HorizontalFieldManager _fieldManagerContext = new HorizontalFieldManager (USE_ALL_WIDTH)
    {
               
    ' public void sublayout (int width, int height) {}
    Super.sublayout (width, height);
    int xPos = 0;
    int yPos = 0;
    Field = getField (0);
                       
    setPositionChild (field, xpos, ypos);
    layoutChild (field, 280, 50);
                       
    Field Field1 = getField (1);
                       
    setPositionChild (Field1, xpos ypos + 80 + 20);
    layoutChild (Field1, 100, 50);

    Field Field2 = getField (2);
                       
    setPositionChild (Field2, xpos ypos + 80 + 145);
    layoutChild (Field2, 100, 50);
                       
    setPosition (150, 220);
    setExtent (width, height);
                        
    }
    public void paint (Graphics graphics)
    {
    graphics.setColor (Color.WHITE);
    Police f = Font.getDefault () .derive (Font.BOLD, 16);
    graphics.setFont (f);
    graphics.drawText ("SEND PIN", 90, 20,0,200);
    graphics.drawText (_userName, 110, 40, 0, 200);
    graphics.setColor (Color.WHITE);
    Super.Paint (Graphics);
    }
             
    };

    _fieldManagerContext.Add (texts);
    _fieldManagerContext.Add (CancelButton);
    _fieldManagerContext.Add (sendButton);
    Add (_fieldManagerContext);
                     
    }

    }

  • clear the editfields by pressing the escape (back on the keyboard)

    Hi all

    I want to erase all editFields by pressing the ESC key. I know I have to implement a keyListener but what I don't know what else to say to clear the editFields.

    If anyone knows how to do this part please.

    Thank you

    I solved the problem. I'm poping the below screen, creating a new instance of this form and pushing it with the help of invokeLater

    / public class KeyListenerImplementation implements KeyListener
    {

    belowScreen of screen private;

    public boolean keyChar (key char, int status, int time)
    {

    If (key == Characters.ESCAPE & UiApplication.getUiApplication () .getScreenCount () > 2)
    {
    belowScreen = UiApplication.getUiApplication () .getActiveScreen () .getScreenBelow ();
                
    If (belowScreen instanceof XXScreen) {}
                    
    UiApplication.getUiApplication () .invokeLater (new Runnable() {}
    public void run() {}
    UiApplication.getUiApplication () .popScreen (belowScreen);

    UiApplication.getUiApplication () .pushScreen (new XXScreen));
    }
    });
    }

    }}

  • Autosizing EditField

    I worked on an EditField autosize intake according to the paint and the value of MaxSize autour rectangle:

    the following code works fine online:

    EditField EF = new EditField ("",null, 8, EditField.FILTER_REAL_NUMERIC)

    {

    public layout zero (int width, int height)

    {

    int x = getFont ().getAdvance("0") * getMaxSize();

    Super.layout (x, getpreferredheight ());

    setExtent (x, getPreferredHeight ());

    } protected void paint (Graphics g)

    {

    g.setColor (Color.GRAY);

    g.drawRect (0,0,getWidth (), getHeight ());

    g.setColor (Color.BLACK);

    Super.paint (g);

    }

    };

    but when I create a class to extend the EditField, it does not work well (the width is set not right)

    public class SizeableEditField extends EditField

    {

    public SizeableEditField()

    {

    new EditField();

    }

    public SizeableEditField (long style)

    {

    new EditField (style);

    }

    public SizeableEditField (label As String, String initialValue)

    {

    new EditField (label, initialValue);

    }

    public SizeableEditField (String initialValue, label As String, style long ,int maxNumChars)

    {

    new EditField (label, initialValue, maxNumChars, style);

    }

    public layout zero (int width, int height)

    {

    int x = this.getFont (.getAdvance("0")) * this. getMaxSize(); / * get the size of the field in pixels of maxChar * /.

    Super.layout (x,this. getPreferredHeight()); / * layout with this space max in mind * /.

    setExtent (x,this. getPreferredHeight()); / * together extend the scope for manager.

    }

    protected void paint (Graphics g)

    {

    g.setColor (Color.GRAY);

    g.drawRect (0,0,this.getWidth(),. getHeight()); g.setColor (color.

    BLACK); Super.paint (g);

    }

    }

    call with:

    SizeableEditField EF = new SizeableEditField ("",null, 8, EditField.FILTER_REAL_NUMERIC);

    The rectangle is painted, but the size is still full hunting, so it seems that x is not calculated on the right.

    No idea why? My debugger will let me see the results of the Expression, os, it is difficult to understand.

    Thanks for help.

    Concerning

    I actually found the problem:

    I need to call super instead of a new EditField

    It works:

    public class SizeableEditField extends EditField

    {

    public SizeableEditField()

    {

    Super ();

    }

    public SizeableEditField (long style)

    {

    Super (style);

    }

    public SizeableEditField (label As String, String initialValue)

    {

    Super (label, initialValue);

    }

    public SizeableEditField (String initialValue, label As String, style long ,int maxNumChars)

    {

    Super (label, initialValue, maxNumChars, style);

    }

    public layout zero (int width, int height)

    {

    int x = getFont ().getAdvance("0") * getMaxSize(); / * get the size of the field in pixels of maxChar * /.

    Super.layout (x, getpreferredheight ()); / * layout with this space max in mind * /.

    this.setExtent (x, getPreferredHeight ()); / * together extend the scope for manager.

    }

    protected void paint (Graphics g)

    {

    g.setColor (Color.GRAY);

    g.drawRect (0,0,this.getWidth(),. getHeight()); g.setColor (color.

    BLACK); Super.paint (g);

    }

    }

Maybe you are looking for

  • Backup (moving) pictures from iPhone to iCloud, stuck!

    Hi all I let go a long day holiday tomorrow and I have a lot of pictures on my iPhone taking over of valuable storage that I know I'll need inevitable for the pictures and videos on vacation. I went into my iCloud > Photos settings and position "Opti

  • can I use a mouse with my ipad air

    can I use a wireless mouse with my ipad air

  • GarageBand iOS not free 9.2.1

    I just got my iPad 2 Air and expected from GarageBand to be free on the App Store, but it seems that I have to pay for it? I have also no "made by Apple applications" in the quick links. Can someone please? Sorry if someone already asked this - I sea

  • Re: Question about extension RAM on Satellite M60

    * Extension of RAM *:What type of memory should I buy if I want to prolong 512 MB to * 2 GB * or more for* Satellite M60 *-182 under Editon Windows XP with Service Pack 2 homeI mean: frequency, symbol, producer, etc. to work properly?oczkim

  • using photo safari

    Hello community, Sorry for my English semi professional, but I hope you understand my question. I can't use my library in Safari. Sometimes I would like to upload a photo, for example a photo of profile on LinkedIn. When I press the "Download" link,