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
Developer
jackofall
Posts: 120
Registered: ‎06-23-2009
My Device: Not Specified
Accepted Solution

Login/Password Screen help needed!

hi,

I am developing a  login password screen for my application.

 

 EditField user=new EditField("User ID:","",10,EditField.FIELD_HCENTER|EditField.FIELD_VCENTER);
 PasswordEditField password=new PasswordEditField("Password:","",10,PasswordEditField.FIELD_VCENTER);
 

 

Functionality wise its ok but i am just wondering how can i 

1. draw editfield into the centre of the screen

2. how can i change the background color of the fields.

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Please use plain text.
Developer
kanaksony
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: Login/Password Screen help needed!

Hi,

 

Plz. go thru the properties of these fields. There are properties like 

 

(1.) EditField.FIELD_HCENTER and EditField.FIELD_VCENTER,which are inherited from " class net.rim.device.api.ui.Field".

      Also you can use Mangers like HorozontalFieldManager and VerticalFieldManager to make it align as you wish..

 

(2.)You will have to override:    public void paint(Graphics g){ }  

 

 

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Please use plain text.
Developer
jackofall
Posts: 120
Registered: ‎06-23-2009
My Device: Not Specified

Re: Login/Password Screen help needed!

I have already tried these VCENTRE AND HCENTERE abut they don't work in my case.

I want to put these two fields in the centre of screen.

Any Suggestions!

Thanks & Regards

Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Please use plain text.
Developer
Shraddha
Posts: 34
Registered: ‎07-25-2008
My Device: Not Specified

Re: Login/Password Screen help needed!

[ Edited ]

how are you adding the field to your screen?

Make a custom Manager that will help you place the fields as u like... 

 

CustomManager cmanager = new CustomManager();

cmanager.add (user); 

cmanager.add(password);

add(cmanager); 

 

The customManager class would extend manager... and it overrides the sublayout method that positions the children of manager.. 

something of this sort... 

 

private class CustomManager extends Manager {
     
        protected CustomManager() {
            super(NO_VERTICAL_SCROLL);
        }
      
        protected void sublayout(int width, int height) {
           if (getFieldCount() > 0) {
                layoutChild(user, width, height);
                layoutChild(password, width, height);
                int y = 10; //this is assumption
                setPositionChild(user, (Display.getWidth()- user.getContentWidth())/2, y);
                y += user.getContentHeight();
                setPositionChild(password, (Display.getWidth() - password.getContentWidth())/2, y);
               
                setExtent(width, Display.getHeight());
            }
        }
 }


To change background colour.. override the paint method...

 

Message Edited by Shraddha on 09-01-2009 03:16 PM
Please use plain text.