EditField Layout

Hi all...

I try to crreate a custom editfield

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Ui;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;

public class BorderEditField extends EditField {

    private Border unFocusBorder = BorderFactory.createBitmapBorder( new XYEdges( 12, 12, 12, 12), Bitmap.getBitmapResource("border.png"));

    BorderEditField() {
        super();
    }

    BorderEditField(long style) {
        super(style);
    }

    BorderEditField(String label, String initialValue) {
        super(label, initialValue);
    }

    BorderEditField(String label, String initialValue, int maxNumChars, long style) {
        super(label, initialValue, maxNumChars, style | Field.USE_ALL_WIDTH);
        super.setFont(getTextFont());
        setBorder(unFocusBorder);
    }    

    public void paint(Graphics g) {
        g.setColor(Color.BLACK);
        g.drawText(super.getText(), 0, 0, DrawStyle.HCENTER + DrawStyle.ELLIPSIS + DrawStyle.TRUNCATE_BEGINNING, getWidth() - 12);
    }

    protected void layout(int width, int height) {
        super.layout(width, height);
    }

    private Font getTextFont() {
        FontFamily alphaSerifFamily = null;
        try {
            alphaSerifFamily = FontFamily.forName("bbalpha serif");
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Dialog.alert(e.getMessage());
        }
        return alphaSerifFamily.getFont(Font.PLAIN, 18, Ui.UNITS_pt);
    }    

}

When I enter a tank that could show more field would create it as a new line, but the text is always on the 1st line

the 2nd line was empty...

How the custom editfield does not display the 2nd line? the 2nd line is an empty text

the text is only 1st line

Well I found a way to make it work

protected void layout(int width, int height) {
        super.setExtent(width, height);
        setExtent( isStyle( USE_ALL_WIDTH ) ? width : getPreferredWidth(), getPreferredHeight() );
    }

    public void updateScreen() {
        invalidate();
    }

IM, add to the bordereditfield

but have to invalidate every time I enter a text.

Tags: BlackBerry Developers

Similar Questions

  • 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

  • How to make a layout like this

    Building an application, but would really better appearance of the user interface.  Here is an application with a user interface similar to what I would like:

    http://www.zmse.com/Tumblr.PNG

    See how the wallpaper is a darker color (easy enough), but then white is a certain type of Manager Layout or something, I'm not familiar with where it has rounded corners, then all EditFields and ButtonFields are in.

    Can someone direct me to something that could help me accomplish something similar?

    Don't know yet, but that's what I found so far:

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800508/...

    Yes. If you put this in your own handler class, you have a good start. the link you have already found gives an example on the positioning of the fields.

    If you use paint or paintbackground is more or less to you

  • EditField automatic extension to a certain height without wordsearch

    CustomEditField wjroke = new CustomEditField(){
    
     public int getPreferredHeight(){
       int h = Font.getDefault().getHeight()* 3;
       //setting the height of edit field as 3 rows
      return h;
     }
    
     public void layout (int width, int height){
    
       super.layout (width, height);
    
       if (getExtent().height < getPreferredHeight()){
           setExtent (width, getPreferredHeight());
       }
     }
    };
    

    THA above code autogrows a custom change the field, but I'd like to stop after a specific height (say 20) has been reached. I tried putting this after

    else{
      setExtent(width, 20);
    }
    

    This kind of work, but when it gets to the height that it hides the words.

    I want to increase the editfield stop but at a certain height, without the words hidden due to the height restriction. Any help will do

    "I want to increase the editfield stop but at a certain height, without the hidden words.

    You mean you want to stop the user entered input when the field has reached a certain size?

    I suspect that the number of characters the user can enter will depend on the phone, the language, the case and the font used, therefore will vary from user to use.  For me, this does not sound like a good user experience.

    Maybe you want to restrict the place occupies the field on the screen, but allow the user to scroll through their text within this space.  If so, this article should help:

    http://supportforums.BlackBerry.com/T5/Java-development/TextBoxField-revisited/Ta-p/548410

  • 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);

    }

    }

  • help with my HorizontalFieldManager &amp; EditFields on the same line, 2nd column is not displayed

    Hi all, I've written a bean (called LabelAndEditField) that sets out a label and editfield as follows

    someLabel

    _________________

    |                                 |

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

    It seems to work perfectly when it is the only component on a line of a

    VerticalFieldManager

    now I want to reuse this compenent such that I can have a screen that looks like

    someLabel another label

    ______________              ______________

    |                                 |             |                                |

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

    and perhaps a third column.

    However, when you add my components of LabelAndEditField, the 2nd does not appear

    I used a HorizontalFieldManager and make

    HFM HorizontalFieldManager = new HorizontalFieldManager();

    HFM. Add (new LabelAndEditField ("someLabel"));

    HFM. Add (new LabelAndEditField ("another label"));

    then I just on the screen

    Add (hfm);

    but it does not show my second column, the second component of the LabelAndEditField

    Here is the snippet of code below, some can please help me get this to display

    (Sorry, that the code of my insert is wacked)

    public class LabelAndEditField extends VerticalFieldManager
    {
        private EditField _editField;
    
        public LabelAndEditField(String label,
                                 String initialValueOfTextField,
                                 int maxChars,
                                 long style)
        {
            super(NO_HORIZONTAL_SCROLL);
    
            add(labelField);
    
            HorizontalFieldManager textMgr = new HorizontalFieldManager(
                    Manager.NO_HORIZONTAL_SCROLL
                    | Manager.NO_HORIZONTAL_SCROLLBAR);
    
            _editField = new EditField("", initialValueOfTextField, maxChars,
                         style | EditField.NO_NEWLINE | EditField.FOCUSABLE
                         | EditField.NON_SPELLCHECKABLE
                         | Field.FIELD_VCENTER | Field.FIELD_LEFT);
    
            textMgr.add(_editField);
    
            add(textMgr);
    
        }
    
    }
    

    and the code that adds as that on the screen

    super(NO_HORIZONTAL_SCROLL); // this is a VerticalFieldManager
    
    HorizontalFieldManager rowMgr =
         new HorizontalFieldManager(Manager.NO_HORIZONTAL_SCROLL
                 | Manager.NO_HORIZONTAL_SCROLLBAR);
    
    LabelAndEditField col1=
           new LabelAndEditField("some label","initial value",12,Field.READONLY);
    
        LabelAndEditField col2=
           new LabelAndEditField("another some label","initial value",12,Field.READONLY);
    
    rowMgr.add(col1);
    rowMgr.add(col2);
    

    did anyone see anything wrong with that?

    As you can see for yourself, there is no place for the mktShare.  Try to go with FlowFieldManager and no HorizontalFieldManager as a container for your gadgets MyLabelAndEditField and see

    There is another possibility:

    The key in the code I provided is the super.layout (myWidth, maxHeight).  This myWidth tells your EditField its maximum size in pixels.  If you want to further restrict the domain, you have several options.  The only problem is - if you limit it too much, you will not be able to see the rest of the field.  To solve this, wrap your EditField (in which you now don't have to override the layout) in a HorizontalFieldManager (HORIZONTAL_SCROLL) (all this inside your MyLabelAndEditField) and limit the Manager rather than the field itself.  Then your customer will be able to scroll through the left field and right.

    In order to limit your HorizontalFieldManager, give him the width that you want in pixels (add that, as a parameter to the constructor of your MyLabelAndEditField) and substitute his sublayout like this:

    HorizontalFieldManager textMgr = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL | Manager.HORIZONTAL_SCROLLBAR) {
      protected void sublayout(int maxWidth, int maxHeight) {
        int myWidth = Math.min(_desiredWidth, maxWidth);
        super.sublayout(myWidth, maxHeight);
      }
    };
    

    Thanks to his style HORIZONTAL_SCROLL, the infield will be almost infinite width, so the EditField inside fortunately "will display" all his characters.

    Then, when you design your MyLabelAndEditField, give him a maximum pixel value.  Say, you want three areas in a row.  Take your Display.getWidth (), subtract the margins planned, divide by 3 and pass that value to each of these areas.  Then add them to a HorizontalFieldManager (line2mgr in your example) and check the result.

    You seem to be competent enough to easily integrate my illegible bubbles in your code - let us know the results.

  • How to make this layout in blackberry

    This screenshot have three editfield I want to do this type of blackberry screen. In the editfield, he should have # in starting and * at the end and it should not be removed on back press.

    The best way to do it is to have the entire field as a HorizontalFieldManager.  This will contain 3 fields, a LabelField to display the ' # ', an EditField and an another LabelField to display the *.

    For the two LabelFields that you will replace object to set the color you want, and then call the super.paint ().

    The trick is the EditField, which, by default, will have plenty of space, it is given.  You should limit its width to make room for the * at the end.  The best way to do this is to replace the sublayout() in the HFM and actually ask the fields yourself.  Here are two KB articles that will help you to do this:

    http://supportforums.BlackBerry.com/T5/Java-development/create-a-custom-layout-manager-for-a-screen/...

    http://supportforums.BlackBerry.com/T5/Java-development/how-to-extend-Manager/Ta-p/446749

    There are other ways to do it, but I think this approach is more flexible.

    Good luck.

  • EditField - cursor stuck in the field

    Hello

    I have an EditField which changes color on onFocus and onUnfocus.  What is strange, is that the slider 'stuck' in the EditField whenever I move (using the trackball) in the field.  I am not able to move out of the EditField until I hit the ESC key.

    Anyone know why this is the case?

    I don't think that it has nothing to do with the definition of the properties available to the field, as all my EditFields behave this way when their "onFocus" and "onUnfocus" attributes are defined.

    (Code pasted below)

    EditField searchtextbox = new EditField(Field.FIELD_VCENTER) {
        public void layout(int width, int height) {
                super.layout(width, height);
                setExtent(250, 25);
                }
    
        public void onFocus(int direction) {
                Background activebgclr = BackgroundFactory
                    .createSolidBackground(Color.WHITE);
                setBackground(activebgclr);
                invalidate();
                select(true);
                }
    
        public void onUnfocus() {
                super.onUnfocus();
                Background inactivebgclr = BackgroundFactory
                        .createSolidBackground(Color.GRAY);
                setBackground(inactivebgclr);
                invalidate();
                }
    };
    

    When the focus is passed to the EditField, you use

    Select (true);

    This puts the ground in "selection mode, more usually used to select pieces of etxt for operations of cut and paste or copy.

    Delete this line and I think that things will work as expected.

  • Cursor/Caret appearing does not in EditField?

    I have an EditField which cursor/insertion sign does not appear.  What Miss me?  Here is my code (and I use 4.5.0 and SIM 8300):

    myEditField = new EditField( "", "", 7, Field.EDITABLE | Field.FIELD_LEFT ){
    
    // inner class method to set field size (setExtent)
    public void layout( int width, int height ) {
      int maxFontWidth = getFont().getAdvance( "W" );
      int fieldSize = myEditField.getMaxSize();
      int newWidth = maxFontWidth * fieldSize;
      setExtent( newWidth, getPreferredHeight() );
    }
    
    // inner class methods to handle changes onFocus/onUnfocus
    public void onFocus( int direction ) {
      super.onFocus( direction );
      invalidate();
    }
    
    public void onUnfocus() {
      super.onUnfocus();
      invalidate();
    }
    
    // inner class method to set text/background colors
    public void paint( Graphics g ) {
      if (myEditField.isFocus()) {
        g.setBackgroundColor( Color.LIGHTGREY );
      } else {
        g.setBackgroundColor( Color.WHITE );
      }
      g.fillRect( 0, 0, getWidth(), getHeight() );
      g.setColor( Color.NAVY );
      g.clear();
      g.drawText( myEditField.getText(), 0, 0 );
      super.paint( g );
    }
    
    }; // end inner class overrides
    

    Try this.  Sorry do not know what I changed to your code at random is went through she change things that did not look right.  However, the 'trick' is the drawFocus.

    In any case, I need to real work, please review, compare, test etc and see how you go.

    myEditField = new EditField( "Label", "Text", 7, Field.EDITABLE | Field.FIELD_LEFT ){
    
      boolean _drawFocus = false;
    
    // inner class method to set field size (setExtent)
    public void layout( int width, int height ) {
      int maxFontWidth = getFont().getAdvance( "W" );
      int fieldSize = this.getMaxSize() + this.getLabel().length();
      int newWidth = maxFontWidth * fieldSize;
      super.layout( newWidth, height );
    }
    
    // inner class methods to handle changes onFocus/onUnfocus
    protected void onFocus( int direction ) {
      super.onFocus( direction );
      invalidate();
    }
    
    protected void onUnfocus() {
      super.onUnfocus();
      invalidate();
    }
    
    protected void drawFocus(Graphics graphics,
                             boolean on) {
      _drawFocus = on;
      super.drawFocus(graphics, on);
      _drawFocus = false;
    }
    
    // inner class method to set text/background colors
    public void paint( Graphics g ) {
      if ( _drawFocus ) {
        super.paint(g);
        return;
      }
      int currCol = g.getColor();
      if (this.isFocus()) {
        g.setBackgroundColor( Color.LIGHTGREY );
      } else {
        g.setBackgroundColor( Color.WHITE );
      }
      g.fillRect( 0, 0, getWidth(), getHeight() );
      g.clear();
      g.setColor( Color.NAVY );
      super.paint( g );
      g.setColor(currCol);
    }
    
    }; // end inner class overrides
    
  • How do layout of research like this

    I want available ot to search, I want to display the field edittext with a button in a rowi used Manager horizontal to display that in a row, but did not display correctly please

    public final class MyScreen extends MainScreen
    {
        HorizontalFieldManager hrm;
        HorizontalFieldManager hrm2;
        ButtonField gobtn;
        EditField editfild;
    
        public MyScreen()
        {
            // Set the displayed title of the screen
            setTitle("search");
            System.out.println(Display.getWidth());
    
            hrm = new HorizontalFieldManager(/*Field.FIELD_RIGHT*/){
    
                protected void sublayout(int maxWidth, int maxHeight) {
                    // TODO Auto-generated method stub
                    super.sublayout(Display.getWidth()-50,maxHeight);  
    
                }
    
            };
            hrm2 = new HorizontalFieldManager(Field.FIELD_RIGHT);
    
            editfild = new EditField();
            editfild.setBorder( BorderFactory.createSimpleBorder( new XYEdges(2, 2, 2, 2),
                    new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK), Border.STYLE_SOLID));
            editfild.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
            gobtn = new ButtonField("go",ButtonField.CONSUME_CLICK);
    
            hrm.add(editfild);
            hrm2.add(gobtn);
    
            this.add(hrm);
            this.add(hrm2);
    
        }
    }
    

    Help me

    I think this will help you.

    public final class LoadingScreen extends MainScreen implements FieldChangeListener
    {
        private EditField editField;
        public LoadingScreen()
        {
            createGUI();
        }
    
        private void createGUI()
        {
            HorizontalFieldManager searchHFM = new HorizontalFieldManager(Field.FIELD_HCENTER);
    
            editField = new EditField()
            {
                protected void layout(int maxWidth, int maxHeight)
                {
                    super.layout(Display.getWidth()-100,50);
                    setExtent(Display.getWidth()-100,50);
                }
            };
            editField.setBorder( BorderFactory.createSimpleBorder( new XYEdges(2, 2, 2, 2),new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK), Border.STYLE_SOLID));
            editField.setBackground(BackgroundFactory.createSolidBackground(Color.WHITE));
            ButtonField goButton = new ButtonField("GO",ButtonField.CONSUME_CLICK|ButtonField.FIELD_RIGHT);
            goButton.setChangeListener(this);
            searchHFM.add(editField);
            searchHFM.add(goButton);
            add(searchHFM);
        }
    
        public void fieldChanged(Field field, int context)
        {
    
        }
    }
    
  • 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

  • EditField aligned right... fields after do not appear

    I've been looking for a while and are still unable to find a solution to this. I read that the EditField uses the ENTIRE WIDTH, but in my scenario, I see not all fields after a custom EditField.

    The EditFields work/display well, but any field after appearing at all

    What I am doing wrong?

    Here is the class that contains my EditFields

    class FieldsManager extends VerticalFieldManager {}
    private int _width;
    private int _height;

    FieldsManager (int width, int height) {}

    Super(Manager.NO_VERTICAL_SCROLL |) Manager.NO_VERTICAL_SCROLLBAR);
    Super (0);
    _width = width;
    _height = height;
       
    Font ft_fields = Font.getDefault () .derive (Font.PLAIN, 16);
    _cityField = new EditField ("", _trip.getLOCATION () .trim () + "," + _trip.getCOUNTRY (), 25, Field.FIELD_RIGHT) {}
    Protected Sub layout (int maxWidth, maxHeight int) {}
    int myWidth = getMaxSize() * getFont () .getAdvance ("W");
    myWidth = Math.min (maxWidth, myWidth);
    Super.Layout (myWidth, maxHeight);
    }

    };
    _cityField.setFont (ft_fields);
    _reasonField = new EditField ("", _trip.getCUSTOMER () .trim (), 25, Field.FIELD_RIGHT) {}
    Protected Sub layout (int maxWidth, maxHeight int) {}
    int myWidth = getMaxSize() * getFont () .getAdvance ("W");
    myWidth = Math.min (maxWidth, myWidth);
    Super.Layout (myWidth, maxHeight);
    }
    };
    _reasonField.setFont (ft_fields);
       
    Add (_cityField);
    Add (_reasonField);

    }

    protected void sublayout (int width, int height) {}
    Field _editField;
    get the total number of areas falling under this Manager of
    int numberOfFields = getFieldCount();
    int y = 0;
    for (int i = 0; i)< numberoffields;="" i++)="">
    _editField = getField (i); get the field
    Are police = _editField.getFont ();
    EditField ef = _editField (EditField);
    int textWidth = Math.max (font.getAdvance (ef.getText ()), police
    .getAdvance('0'))
    + font.getAdvance(' ');
    layoutChild (_editField, textWidth, height);
    setPositionChild (_editField, width - textWidth, y);
    y += _editField.getHeight ();
    }
       
    setExtent (width, height);
    }

    public int getPreferredHeight() {}
    return _height;
    }

    public int getPreferredWidth() {}
    return _width;
    }

    }

    It is added to the main screen. All the fields added in the future do not appear... help?

    Check the values in your sublayout method using the debugger

  • EditField with button on a single line

    Hello

    How can I put a text field and a button on the same line field?

    Is there a way to recover the image of contacts to use as a bitmap on the button field?

    How is it possible that it is not a component already built for an edit field phone number with key contacts on the side?

    Another question: is it possible, on the same line, add a horizontally centered label, and a button left-aligned?

    Thank you

    an editfield uses the width full-screen by default. You can change this by substituting getPreferredWidth or by using a custom layout.

    Yes. I use this code:

    if (blackberryContact.countValues(BlackBerryContact.PHOTO) > 0) {
      byte[] photoEncoded = blackberryContact.getBinary(BlackBerryContact.PHOTO, 0);
      byte[] decodedPicture = Base64InputStream.decode(photoEncoded, 0, photoEncoded.length)
    }
    

    I guess that the field is not commonly used and can be developed easily.

    Yes, with a custom presentation: http://supportforums.blackberry.com/t5/Java-Development/Create-a-custom-layout-manager-for-a-screen/...

  • EditField and checkboxfield on the same line

    public CheckFileScreen()
        {
            vfm = new VerticalFieldManager();
            left = new HorizontalFieldManager( Field.FIELD_LEFT);
            right = new HorizontalFieldManager( Field.FIELD_RIGHT);
            _Id = new EditField("Id : ", "", 6, EditField.FILTER_NUMERIC);
            _check = new CheckboxField("check", false);
                    left.add(_Id);
            right.add(_check);
            vfm.add(left);
            vfm.add(right);
            add(vfm);
            add(new SeparatorField());
        }
    

    on my above code tries to _id and _check on the same line, but the screen has been mess up

    +---------------

    | ID:

    | # check

    +----------------

    I want to create has been

    +----------------------

    | ID: # check

    +-----------------------

    could someone help me with this?

    This is the first time make app with GUI

    Gentlemen.

    slow down, please!

    Absolutely, totally useless any Manager available personalized for that! In order to organize two or more fields in a 'line', you just all of them to the same HorizontalFieldManager! The manager then places them from left to right in the order that you add them.

    That said - you have a slight problem in your EditField. EditField is "width-hungry" - it consumes the entire width, it is given, do not leave anything for the rest fields. To combat that, to deceive him into thinking he's got less space. We will give him what he needs to label 6 larger figures (s '8' or '9's, not '1') and a space for the padding. We will then have something like:

    _Id = new EditField("Id : ", "", 6, EditField.FILTER_NUMERIC) {
      protected void layout(int width, int height) {
        Font myFont = getFont();
        int myWidth = myFont.getAdvance(getLabel()) + myFont.getAdvance("8") * 6 + myFont.getAdvance(" ");
        super.layout(Math.min(myWidth, width), height);
      }
    };
    _check = new CheckboxField("check", false);
    HorizontalFieldManager hfm = new HorizontalFieldManager();
    hfm.add(_Id);
    hfm.add(_check);
    add(hfm);
    

    Enjoy!

  • Question of the development of EditField and LabelField in HorizontalFieldManager

    I actually want a custom editfield (a label with a textbox), when he got focus on this textbox draws a border of climax, and I want the label got the same effect, however, I drew a border outside the text easily because of the text box could receive focus , here is my code:

    public class MyTextField extends EditField
    {
        public MyTextField()
        {
            super();
        }
    
        public void layout(int width, int height)
        {
            super.layout(width, height);
        }
    
        protected void paint(Graphics g)
        {
            if(g.isDrawingStyleSet(Graphics.DRAWSTYLE_FOCUS))
            {
                setBorder(BorderFactory.createRoundedBorder(new XYEdges(6, 6, 6, 6), 0x186DEF, Border.STYLE_SOLID));
            }else{
                setBorder(BorderFactory.createRoundedBorder(new XYEdges(6, 6, 6, 6), Color.GRAY, Border.STYLE_SOLID));
            }
    
            super.paint(g);
         }
    }
    

    And I use this code to show in screen

           HorizontalFieldManager hfm=new HorizontalFieldManager();
            LabelField label=new LabelField("something");
            MyTextField text=new MyTextField();
    
            hfm.add(label);
            hfm.add(text);
            add(hfm);
    

    Is there a way to implement that when the textbox has got the update at the same time also changed the color of the text of the label.

    set a Boolean flag that you record in paint, set it on the ground (from outside) and invalid call to redraw.

Maybe you are looking for