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
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10
Accepted Solution

Problem in editing the CustomField

Hi

I have made a CustomField class by extending Basic edit field.But it is not editable though i have set it as editable in style parameter.

What is the problem?

Please use plain text.
Developer
simon_hain
Posts: 16,190
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Problem in editing the CustomField

crystal ball is all snowy, maybe you better post the code.
----------------------------------------------------------
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
Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in editing the CustomField

Here is the field

 

                FirstName= new CustomEditField("First Name: "+firstName, Color.BLACK, Color.GRAY, 0);
                FirstName.setEditable(true);
                FirstName.setMargin(5, 20, 10, 8);
                FirstName.setChangeListener(this);
                mainVerticalManager.add(FirstName);

 

But this field is not editable?

Please use plain text.
Developer
simon_hain
Posts: 16,190
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Problem in editing the CustomField

the code of the CustomEditField would be needed.
----------------------------------------------------------
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
Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in editing the CustomField

Ok

here is the code..

public CustomEditField(String label, int foregroundColor, int backgroundColor, long style)
    {
        super(style);
        this.label = label;
        this.foregroundColor = foregroundColor;
        this.backgroundColor = backgroundColor;
    }
        
    protected void layout(int width, int height)
    {
        setExtent(width, getFont().getHeight()+20);
    }
    protected void paint(Graphics graphics)
    {
        graphics.setBackgroundColor(backgroundColor);
        graphics.clear();
        graphics.setColor(foregroundColor);
        graphics.drawText(label, 24, 8);
    }

Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in editing the CustomField

I suggest you read this:

http://supportforums.blackberry.com/t5/Java-Development/Create-custom-fields/ta-p/444962

 

Think about what you have done with these methods:

    protected void layout(int width, int height)
    {
        setExtent(width, getFont().getHeight()+20);
    }

 

layout does more than just specify the size of the Field.

 

    protected void paint(Graphics graphics)
    {
        graphics.setBackgroundColor(backgroundColor);
        graphics.clear();
        graphics.setColor(foregroundColor);
        graphics.drawText(label, 24, 8);
    }

 

paint has to consider more than just the text - what about the cursor and focus indication for example. 

 

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in editing the CustomField

Actualy i want to make a edit field that contains text with blackground color gray.

 

FirstName: xyz

and its editable.

 

Please use plain text.
Developer
peter_strange
Posts: 19,607
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in editing the CustomField

You can do that just setting the Background on a standard Field.

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in editing the CustomField

 FirstName= new EditField("First Name : ",""+labelName1)
                {
                    protected void paint(Graphics graphics)
                    {
                        graphics.setBackgroundColor(Color.GRAY);
                        graphics.clear();
                        graphics.setColor(Color.BLACK);
                        graphics.drawText("First Name: "+labelName1,30 , 6);
                    }
//                    protected void layout(int width, int height)
//                    {
//                        
//                        super.layout(width, height);
//                    }
                };
                FirstName.setEditable(true);
                mainVerticalManager.add(FirstName);

 

this field is not editable?

how to edit this field?

Please use plain text.
Developer
simon_hain
Posts: 16,190
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Problem in editing the CustomField

use setBackground
----------------------------------------------------------
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
Please use plain text.