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 Developer
Posts: 37
Registered: ‎03-31-2009
My Device: Not Specified

Background Color NOT Filling Out Border Padding

The following code was taken from one of Blackberry's own JDE sample apps. The sample app intends to show the uses of it's decor class. It applies a rounded border with 10pxl padding to a Field object and then applies a background color to it. But when the background color is applied it doesn't fill out the border padding!! *bangs head on desk repeatedly* is there a way to force the background out to the edge? or should I use another method?

 

XYEdges thickPadding = new XYEdges(10, 10, 10, 10); RichTextField simpleField = new RichTextField("Solid rounded border, solid background"); Border roundedBorder = BorderFactory.createRoundedBorder(thickPadding, Border.STYLE_SOLID); Background solidBackground = BackgroundFactory.createSolidBackground(Color.LIGHTSTEELBLUE); simpleField.setBorder(roundedBorder); simpleField.setBackground(solidBackground); add(simpleField);

 

 

 

Developer
Posts: 90
Registered: ‎02-27-2009
My Device: Not Specified

Re: Background Color NOT Filling Out Border Padding

I had a similar issue and solved it by manually setting the border color.

 

 

HorizontalFieldManager blankTop = new HorizontalFieldManager(Field.USE_ALL_WIDTH); XYEdges padding = new XYEdges(5, 0, 0, 5); XYEdges colors = new XYEdges(0x0b1c31, 0x0b1c31, 0x0b1c31, 0x0b1c31); blankTop.setBackground(BackgroundFactory.createSolidBackground(0x0b1c31)); blankTop.setBorder(BorderFactory.createSimpleBorder(padding, colors, Border.STYLE_SOLID));

 

 

 

New Developer
Posts: 37
Registered: ‎03-31-2009
My Device: Not Specified

Re: Background Color NOT Filling Out Border Padding

Thank you for your response! Sorry I've been away, I'll check it out as soon as I can.
Developer
Posts: 90
Registered: ‎02-27-2009
My Device: Not Specified

Re: Background Color NOT Filling Out Border Padding

No problem. If you don't mind, please mark the thread as resolved.
New Developer
Posts: 37
Registered: ‎03-31-2009
My Device: Not Specified

Re: Background Color NOT Filling Out Border Padding

Not resolved. The code you provided changes the color of the border, but it does not color the padding.
Developer
Posts: 57
Registered: ‎01-29-2009
My Device: Not Specified

Re: Background Color NOT Filling Out Border Padding

See the custombuttonsdemo in the JDE itself.

 

Regards

Vaikunth

Developer
Posts: 29
Registered: ‎06-23-2009
My Device: Not Specified

Re: Background Color NOT Filling Out Border Padding

Any resolution here? I am having the same issue.

 

Here is my custom field paint method:

 

        protected void paint(Graphics g) {
            if (hasFocus) {
                g.setBackgroundColor(backgroundFocusColor);
                g.clear();
            }

             ...
            super.paint(g);
        }

 

The field has a non-zero padding and the padding does not get filled.

Developer
Posts: 29
Registered: ‎06-23-2009
My Device: Not Specified

Re: Background Color NOT Filling Out Border Padding

Just found this in the documentation of getExtent():

 

getExtent

public final XYRect getExtent()

Retrieves this field's extent (region occupied in its manager's child region). The extent is the union of the field's drawable area, its area for padding, and its area for borders. The field is not able to draw in its padding or border areas. Only the field's manager, its manager's manager, etc., may draw in the padding and border areas.

Developer
Posts: 29
Registered: ‎06-23-2009
My Device: Not Specified

Re: Background Color NOT Filling Out Border Padding

Just found this in the documentation of getExtent() :

 

getExtent

public final XYRect getExtent()

    Retrieves this field's extent (region occupied in its manager's child region). The extent is the union of the field's drawable area, its area for padding, and its area for borders. The field is not able to draw in its padding or border areas. Only the field's manager, its manager's manager, etc., may draw in the padding and border areas.