Alignment of my editField

Hello

I'm working on JDE 4.2.I Put center manager and other components of the field. But I wasn't able to move only editfield. Please tell me wat can be mistake.

That's how I add as below.

But the cursor remains at the same position like that.

passwordField = new PasswordEditField("",            "",1000,PasswordEditField.FIELD_HCENTER){                        public void paint(Graphics g) {                                super.paint(g); 
g.drawRect(2,0, getWidth(), getHeight());

}
};

EDIT: Edition at the request of the posters

not serious.  I'm afraid I can't help with the problem of moving the cursor.  The cursor moves very well for me.

Regard to the alignment of the PasswordEditField, you must actually do in your Manager.

   protected void sublayout(int width, int height)
    {
        Field field;
        //get total number of fields within this manager
        int numberOfFields = getFieldCount();
        int y = 0;
        for (int i = 0; i < numberOfFields; i++)
        {
            field = getField(i); //get the field
            if (field instanceof PasswordEditField)
                layoutChild(field, (width / 8 * 6), height); //lay out the field
            else
                layoutChild(field, width, height); //lay out the field

            setPositionChild(field, (width - field.getWidth()) >> 1, y); //set the position for the field

            y += field.getHeight();
        }
        setExtent(width, height);
    }

That means this code, it puts 1/8 spacing on each side.

And if you remember Peter post, you can probably do with setMargin as well.

Tags: BlackBerry Developers

Similar Questions

  • Place aligned EditField and BitmapField on PopupScreen

    Hello guys '

    I want to place aligned EditField and BitmapField on PopupScree. But I can't place these 2 fields.

    I used HorizontalFieldManager and VerticalFieldManager of the place. It does not work.

    HorizontalFieldManager hmanager = new HorizontalFieldManager();
    VerticalFieldManager vmanagerRight = new VerticalFieldManager();
    VerticalFieldManager vmanagerLeft = new VerticalFieldManager();
    
    statusLabel = new LabelField();
    direction = new Bitmap(15, 15);
    directionBitmap = new BitmapField(direction);
    
    vmanagerLeft.add(directionBitmap);
    vmanagerRight.add(statusLabel);
    
    hmanager.add(vmanagerLeft);
    hmanager.add(vmanagerRight);
    
    progressPopup = new PopupScreen(hmanager);
    
    ...
    

    What solution is the best?

    Tnx guys

    What you see?  The fields appearing at all or are they not be presented as you wish?

  • 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

  • Alignment editfields &amp; bitmapfield using managers

    Hello

    I am the creation of screen which has 4 editfields basic and in the an of the fundamental change field I want to add a question mark image (which is a field that is focusable)

    all editfields have a limit of 64 characters, and it will not allow NEW_LINE (so NEW_NEWLINE)

    The arrangement is as follows

    basicedit1: aaa

    basicedit2: bbbb?

    basicedit3: ccccc

    basicedit4: ddddd

    I use a horizontal for the basicedit2 Manager & the question mark field.

    This Manager and other areas of the basic edition are added to the vertical field Manager

    The problem is when I enter 64 char basicedit1 (when the w & m when the tank move to the new line) moving the image to the left. How can I avoid this in basic edit2 the tank behind the image?

    How can I implement this better

    You could add a pair of VerticalFieldManagers to the HorizontalFieldManagers that make your line for a column as layout within each line.

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

  • CustomTextBox align

    Hi all

    I use code kindly offered online by Dorian.

    Now, I am trying to align this text box toward the Center.

    Does anyone know what I need to change to achieve this please?

    import net.rim.device.api.ui.Manager;
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.component.EditField;
    import net.rim.device.api.ui.component.BasicEditField;
    import net.rim.device.api.system.EncodedImage;
    import net.rim.device.api.system.Bitmap;
    import net.rim.device.api.system.Display;
    import net.rim.device.api.ui.Graphics;
    import net.rim.device.api.system.Characters;
    import net.rim.device.api.math.Fixed32;
    import net.rim.device.api.ui.DrawStyle;
    import net.rim.device.api.ui.Font;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.container.MainScreen;
    
    public class CustomTextBox2 extends Manager{    /**     * Default margins     */
        private final static int DEFAULT_LEFT_MARGIN = 0;
    
    private final static int DEFAULT_RIGHT_MARGIN = 10;
    private final static int DEFAULT_TOP_MARGIN = 5;
    private final static int DEFAULT_BOTTOM_MARGIN = 5;        /**     * Default paddings     */
    private final static int DEFAULT_LEFT_PADDING = 10;
    private final static int DEFAULT_RIGHT_PADDING = 10;
    private final static int DEFAULT_TOP_PADDING = 5;
    private final static int DEFAULT_BOTTOM_PADDING = 5;
    /**     * Margins around the text box     */
    private int topMargin = DEFAULT_TOP_MARGIN;
    private int bottomMargin = DEFAULT_BOTTOM_MARGIN;
    private int leftMargin = DEFAULT_LEFT_MARGIN;
    private int rightMargin = DEFAULT_RIGHT_MARGIN;
    /**     * Padding around the text box     */
    private int topPadding = DEFAULT_TOP_PADDING;
    private int bottomPadding = DEFAULT_BOTTOM_PADDING;
    private int leftPadding = DEFAULT_LEFT_PADDING;
    private int rightPadding = DEFAULT_RIGHT_PADDING;
    /**     * Amount of empty space horizontally around the text box     */
    private int totalHorizontalEmptySpace = leftMargin + leftPadding
            + rightPadding + rightMargin;
    /**     * Amount of empty space vertically around the text box     */
    private int totalVerticalEmptySpace = topMargin + topPadding
            + bottomPadding + bottomMargin;
    /**     * Minimum height of the text box required to display the text entered     */
    private int minHeight = getFont().getHeight() + totalVerticalEmptySpace;
    /**
     * Width of the text box     */
    private int width;
    /**     * Height of the text box     */
    private int height = 45;
    /**     * Background image for the text box     */
    private EncodedImage backgroundImage;
    /**     * Bitmap version of the backgroundImage.
     * Needed to reduce the calculation overhead incurred by
     * scaling of the given image
     * and derivation of Bitmap from the
     * EncodedImage every time it is needed.
     */
    private Bitmap bitmapBackgroundImage;
    /**
     * The core element of this text box
     */
    private EditField editField;
    MainScreen theScreen;
    //private BasicEditField editField;
    //private String entireText;
    public CustomTextBox2(int width2, int height, MainScreen aScreen)
    {
         super(0);
        theScreen = aScreen;
        // Let the super class initialize the core
    
        width = width2 + 20;
        // An edit field is the sole field of this manager.
        editField = new EditField();
        //editField = new CustomEditField();
        add(editField);
    }
    
    /*
    public CustomTextBox2(EncodedImage backgroundImage)
    {
        this();
    
    setBackgroundImage(backgroundImage);
        }
     * */
    
        public void setSize(int width, int height)
        {
            boolean isChanged = false;
            if (width > 0 // Ignore invalid width
                    && this.width != width)
            {
                this.width = width;
                isChanged = true;
            }
            // Ignore the specified height if it is less
            // than the minimum height required to display the text.
            if (height > minHeight && height != this.height)
            {
                this.height = height;
                isChanged = true;
            }
            // If width/height has been changed and background image
            // is available, adapt it to the new dimension
            if (isChanged == true && backgroundImage != null)
            {
                bitmapBackgroundImage = getScaledBitmapImage(backgroundImage,
                        this.width - (leftMargin+rightMargin),
                        this.height - (topMargin+bottomMargin));
    
            }
        }
    
        public void setWidth(int width)
        {
            if (width > 0 && width != this.width)
            {
                this.width = width;
                // If background image is available, adapt it to the new width
                if (backgroundImage != null)
                {
                    bitmapBackgroundImage = getScaledBitmapImage(backgroundImage,
                            this.width - (leftMargin+rightMargin),
                            this.height - (topMargin+bottomMargin));
                }
            }
        }
        public void setHeight(int height)
        {
            // Ignore the specified height if it is
            // less than the minimum height required to display the text.
            if (height > minHeight)
            {
                this.height = height;
                // If background image is available, adapt it to the new width
    
                if (backgroundImage != null)
                {
                    bitmapBackgroundImage = getScaledBitmapImage(backgroundImage,
                            this.width - (leftMargin+rightMargin),
                            this.height - (topMargin+bottomMargin));
                }
            }
        }
        public void setBackgroundImage(EncodedImage backgroundImage)
        {
            this.backgroundImage = backgroundImage;
            // Consider the height of background image in
            // calculating the height of the text box.
            // setHeight() does not ensure that specified
            // height will be in effect, of course, for valid reasons.
            // So derivation of Bitmap image in the setHeight() method is not sure.
            setHeight(backgroundImage.getHeight() + topMargin + bottomMargin);
            if (bitmapBackgroundImage == null)
            {
                bitmapBackgroundImage = getScaledBitmapImage(backgroundImage,
                        this.width - (leftMargin+rightMargin),
                        this.height - (topMargin+bottomMargin));
            }
        }
        /**     * Generate and return a Bitmap Image scaled according
         * to the specified width and height.
         *
         * @param image     EncodedImage object
         * @param width     Intended width of the returned Bitmap object
         * @param height    Intended height of the returned Bitmap object
         * @return Bitmap object     */
        private Bitmap getScaledBitmapImage(EncodedImage image, int width, int height)
        {
            // Handle null image
            if (image == null)
            {
                return null;
            }
            int currentWidthFixed32 = Fixed32.toFP(image.getWidth());
            int currentHeightFixed32 = Fixed32.toFP(image.getHeight());
            int requiredWidthFixed32 = Fixed32.toFP(width);
            int requiredHeightFixed32 = Fixed32.toFP(height);
            int scaleXFixed32 = Fixed32.div(currentWidthFixed32, requiredWidthFixed32);
            int scaleYFixed32 = Fixed32.div(currentHeightFixed32, requiredHeightFixed32);
            image = image.scaleImage32(scaleXFixed32, scaleYFixed32);
            return image.getBitmap();
        }
        protected void sublayout(int width, int height)
        {
            // We have one and only child - the edit field.
            // Place it at the appropriate place.
            Field field = getField(0);
            layoutChild(field, this.width - totalHorizontalEmptySpace,
                    this.height - totalVerticalEmptySpace);
            setPositionChild(field, leftMargin+leftPadding, topMargin+topPadding);
            setExtent(this.width, this.height);
        }
        public void setTopMargin(int topMargin)
        {
            this.topMargin = topMargin;
        }
        public void setBottomMargin(int bottomMargin)
        {
            this.bottomMargin = bottomMargin;
        }
        protected void paint(Graphics graphics)    {
            // Draw background image if available, otherwise draw a rectangle
            if (bitmapBackgroundImage == null)
            {
                //graphics.drawRect(leftMargin, topMargin,                                 width - (leftMargin+rightMargin),                                 height - (topMargin+bottomMargin));
                graphics.setColor(0x000000);
                graphics.drawRoundRect(leftMargin, topMargin,
                        width - (leftMargin+rightMargin),
                        height - (topMargin+bottomMargin), 15, 15);
                graphics.setColor(0xffffff);
                graphics.fillRoundRect(leftMargin, topMargin,
                        width - (leftMargin+rightMargin),
                        height - (topMargin+bottomMargin), 15, 15);
            }
            else
            {
                graphics.drawBitmap(leftMargin, topMargin,
                        width - (leftMargin+rightMargin),
                        height - (topMargin+bottomMargin),
                        bitmapBackgroundImage, 0, 0);        }
            // Determine the rightward text that can fit into the visible edit field
            EditField ef = (EditField)getField(0);
            String entireText = ef.getText();
            boolean longText = false;
            String textToDraw = "";
            Font font = getFont();
            int availableWidth = width - totalHorizontalEmptySpace;
            if (font.getAdvance(entireText) <= availableWidth)
            {
                textToDraw = entireText;
            }
            else
            {
                int endIndex = entireText.length();
                for (int beginIndex = 1; beginIndex < endIndex; beginIndex++)
                {
                    textToDraw = entireText.substring(beginIndex);
                    if (font.getAdvance(textToDraw) <= availableWidth)
                    {
                        longText = true;
                        break;
                    }            }        }
            if (longText == true)
            {
                // Force the edit field display only the truncated text
                ef.setText(textToDraw);
                // Now let the components draw themselves
                super.paint(graphics);
                // Return the text field its original text
                ef.setText(entireText);
    
            }
            else
            {
                super.paint(graphics);
            }
        }
        public int getPreferredWidth()
        {
            return width;
        }
        public int getPreferredHeight()
        {
            return height;
        }
        protected boolean keyChar(char ch, int status, int time)
        {
           Log.info("KEYCHAR " + ch);
            switch(ch){
    
                case Characters.ENTER:
                    try
            {    Log.info("KEYCHAR 1");
                       // theScreen.textButton.getChangeListener().fieldChanged(theScreen.textButton, theScreen.textButton.getIndex());
       Log.info("KEYCHAR 2");
              // f.getChangeListener().fieldChanged(f, f.getIndex());
            }
            catch (Exception e)
            {
            Log.info("Error at fcn" + e);
            }
                    return true;
    
            }
    Log.info("KEYCHAR 0");
    //theScreen.textButton.getChangeListener().fieldChanged(theScreen.textButton, theScreen.textButton.getIndex());
    
            return super.keyChar(ch,status,time);
        }
        public String getText()
        {
            return ((EditField)getField(0)).getText();
        }
        public void setText(final String text)
        {
            ((EditField)getField(0)).setText(text);
        }
       }
    

    You are missing a centerpiece - the ability to set the bits of style on this field. If you add a constructor that accepts a parameter of long style and has great (style) as the first operator, you should be able to create with the FIELD_HCENTER style bit and add it to a Manager honor this indicator (for example, VerticalFieldManager).  Then it will be automatically centered horizontally by the parent Manager.

    It is the same on FIELD_VCENTER and, say, HorizontalFieldManager.

  • Newbie - editfields put in shape on the screen

    HI all, it seems that it should be simple.

    My class screen extends screen and adds a bunch of EditFields.  How to get the labels to align vertically along the left margin of the screen and the data input fields line up vertically along the right edge of the screen?  Please, look at the default AppointmentItem for what I'm trying to accomplish.

    Thank you, Steve

    There is no stock management that does what you want (if I understand the question).

    Fields of change all take them across the width of the default view; the label takes as much as he needs and the text box takes the rest.

    When your right - justify the text box, how much space you take and what direction should the text fill the input box?

    I think that you might be looking at the date fields on the screen that you mention?

    In any case, it will take you either write your own editing field custom, one of those that exist, patch or extend something upward with a HorizontalFieldManager containing a label separate fiekd and the input field (of the sort that you can justify the two fields independently).

  • 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();
        }
    
    }
    
  • Move the 3 letters for word-how to align results in Keynote?

    As you can see, I am to spoil it enormously. What step I got?

    Thank you.

    In your example, I can't tell what you are trying to do.

    I'll assume that the word "cat" is your difficulty. If you have each of the letters in an individual text box and then select all and choose align > way. If the letters are not text boxes you have set "basic" for the letter t and maybe "character spacing" to the other letters. Enter these words in the help.

  • How to change the default alignment of text in the cells in a table on the demand for numbers?

    I'm new to Mac. I own a MacBook pro MF839HN/A and currently using the 3.6.2 release NUMBERS (2577). I want to know if I can change the default alignment of text in the cell in a table of NUMBERS application? Also, when I select all the cells in a table to change their alignment, I can only change the horizontal alignment of the text and not the vertical alignment. To change the vertical alignment of the text in a cell, I have to select them individually. Help me with two questions.

    The only way I know is to create a table that is set up as you like, then save the empty document as a template customized by using the menu item "file > save as template:

  • moving text, very slightly to align with precision

    Hello

    I do a menu in pages and I would like to move some of the prices on the right side, so they all line up nicely. I don't want to choose all the 'align right' as then the food not all vertically aligned. Is there a command or action that allows me to just move the desired text by small steps?

    Thank you

    There is no adjustment convenient to move the text in small increments. Maybe with InDesign, Quark, or Scribus, but not in Pages.

    If you want your menu items and prices aligned differently and especially perfectly aligned to the right, then use a table that has cell formatting for this purpose.

  • Paging in the poorly aligned table of contents

    As you can see in the screenshot below, the pagination is right-aligned, sometimes in the table of contents, and sometimes it seems all wrong. What should I do to fix this?

    Hello joachim,.

    Pages 5.6.2 on OS X El Capitan 10.11.5

    Menu > view > show rules.

    You can select (click) each level (Style) of the Table of contents and view the parameters of the rule.

    With the second level selected, look in Control Panel of Format > text > tabs

    Please call with questions.

    Kind regards

    Ian.

  • Facebook ask for enable cookies when I already did. Page is white and blue just link on the left-aligned words.

    Facebook appears on white background and text, some with links left alignment.

    allowed, history, cookies, cache, everything I searched on google.

    cookies are already enabled.

    all other websites are ok except fb.

    pls help.

    Apparently, facebook could have updated their ads stuff that make my anti-ad on my phone does not not with facebook. fuck Facebook.

  • How can I display a grid of horizontal alignment in Pages.

    How can I display a grid of horizontal alignment in pages. I can show a vertical, but there seems to be no option to show a horizontal. I use El Capitan with maps, version 5.6.2 Pages.

    Pages v5.6.2 has horizontal and vertical guides, but no grid. The vertical guide is enabled in the menu Pages: preferences: sovereign.

    With the two visible leaders after menu display: display the rule, place the cursor of the black needle on the edge of the respective sovereign and then click. When you see the following icon, drag the new guide in your document. Several vertical and horizontal guides may be present. The view menu has an element of Guides to hide menu or erased.

    • Indicator of horizontal ruler guide
    • Indicator of vertical ruler guide
  • Advice needed on the alignment of the text in an e-mail.

    I'm developing an email with a small logo (with a web link) with a descriptive text to the right. I tried to put a picture here, but it won't download for some reason any so posted it here: http://imgur.com/gallery/lHRD8VC/new

    I can align the text on the image, but when it falls in the second line, it drops below the logo image and left justified. I want it all back right of the logo to look neat. I know that I can use the tap and space to get what I want in the email, but she is shown in a smaller window when it is created, all goes pear-shaped.

    Any help would be appreciated.

    use a table. 1 row end on 2 columns. Picture in the text first, in the second.

Maybe you are looking for

  • Unable to download purchased on iPad app

    I bought the Stylebook app on my iPhone. But when I try to download same app on my iPad, it shows that it is purchased, but not able to download. Any suggestions? The cloud icon is grey and not usable.

  • How do I know what error codes a particular VI can give?

    Hello I tried to write a good error handler (and not one that sends just errors through the application), but I was not able to find information about error codes specific VI can lift. I searched the forum and google but have not found anything on th

  • INSTALLATION DIRECTORY

    Download Command and Conquer Generals of U-torrent.  All downloaded ok but you can not run the game from the icon of the game, he said: "you must run the game from the installation directory. What is the install directory, where can I find and that I

  • 8 GB clip do not find files

    Hello I have a new 8 GB Sansa Clip which was not recognized by my PC Win XP. I plugged on another Win XP PC and it was recognized at that time here I updated the firmware to the version.35.  He always has been not recognized by my PC until I put the

  • keyboard not working properly

    I HAVE a PROBLEM where the letters on the key edge that a number number only of central unit of the screen no letters for example k2 l3 if I hold down the fn key chicken that they wor2