blackberrycustomizationblackberry-eclipse-plugin

customized editable text field with predefined width and height


enter image description here

i am developing a mobile app in blackberry 7,i need to create a editable text field as shown in below figure with save and clear button.initially it has to show customized edittext field with predefined width(fixed as it should not exceed the defined layout) and height,and automatically get appended by new line if user requires to enter more characters after reaching predefined space as user keeps filling the field.

i googled, but i did not get any source which is similar to this.please help me by providing any suggestion or with samples


Solution

  • Blackberry fields decide their size in their layout field. I'm not entirely sure what EditField does in its layout, but I was able to get the behaviour you want by setting the extent. Every time the edit field text will wrap, layout will be triggered so that it can grow.

        EditField editField = new EditField()
        {
            private final int MIN_HEIGHT = 200;
    
            protected void layout(int width, int height)
            {
                super.layout(width, height);
                if (getHeight() < MIN_HEIGHT)
                {
                    setExtent(getWidth(), MIN_HEIGHT);
                }
            }
        };
        editField.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1, 1, 1, 1)));
        add(editField);