Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
Posts: 3
Registered: ‎03-18-2010
My Device: 8900
My Carrier: Developer
Accepted Solution

label field and edit text field in vertical field manager

Hi, am new to blackberry development. Am developing an application in which i placed label field and edit field in two vertical field manger and placing them in a horizontal field manager, but when run this i can't see the label field only text field i can see, am doin BB 4.7, following is my code

 

LabelField Name = new LabelField("First Name:")
        {
            public void paint(Graphics g)
            {
                super.paint(g);
                g.setColor(Color.BLACK);
                Font font = this.getFont().derive(Font.DROP_SHADOW_RIGHT_EFFECT | Font.ENGRAVED_EFFECT, h);
                this.setFont(font);
            }
        };
 
        FirstName = new EditField("Name", "", 25, EditField.FILTER_DEFAULT|FIELD_RIGHT){
              public void paint(Graphics g) {
                  getManager().invalidate();
                  Font font = this.getFont().derive(Font.DROP_SHADOW_RIGHT_EFFECT| Font.ENGRAVED_EFFECT, h);
                  this.setFont(font);
                  g.drawRect(6, 0, (int) (Display.getWidth()/1.8), getHeight());
                  super.paint(g);
              }
        };
        HorizontalFieldManager hrMgr = new HorizontalFieldManager();
        final VerticalFieldManager vfMgr2 = new VerticalFieldManager();
        VerticalFieldManager vfMgr1 = new VerticalFieldManager()
        {
            protected void sublayout(int width, int height)
            {          
                int w = (int) (Display.getWidth() - vfMgr2.getPreferredWidth()-20);
                Field field;
                int fieldCount;
                int x = 0;
                int y = 0;

                fieldCount = getFieldCount();
                int d = (int) ((Display.getWidth()/4.5));
                for(int i = 0; i < fieldCount; i++)
                {
                    field = getField(i);
                    setPositionChild(field, x, y);
                    layoutChild(field, w, height);
                    y += field.getContentHeight();
                }
                setExtent(d, y);
            }
        };        
        vfMgr1.add(Name);
        vfMgr2.add(FirstName);
        hrMgr.add(vfMgr1);
        hrMgr.add(vfMgr2);
        add(hrMgr);

 

The same one s working fine if place a object choice field instead of edit text field that is i can see both label field and object choice field in a single line but its not in the case of edit text field, some one please help me on this, Thanhs in advance.

Cheers,
Parthiban
Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: label field and edit text field in vertical field manager

take a look at this code:

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

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Contributor
Posts: 3
Registered: ‎03-18-2010
My Device: 8900
My Carrier: Developer

Re: label field and edit text field in vertical field manager

Thanks for ur valuable reply Mr.simon,

     But i achieved my target by adjusting the width of my vertical field manger and got a solution.. These are the changes i have made in my sublayout...

 protected void sublayout(int width, int height)
            {          
                int w = (int) (Display.getWidth()/1.3);
                Field field;
                int fieldCount;
                int x = 10;
                int y = 0;

                fieldCount = getFieldCount();
                int d = (int) ((Display.getWidth()/3));
                for(int i = 0; i < fieldCount; i++)
                {
                    field = getField(i);
                    setPositionChild(field, x, y);
                    layoutChild(field, w, height);
                    y += field.getContentHeight();
                }
                setExtent(d, y);
            }
        }; 

 

 

Cheers,
Parthiban