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
Trusted Contributor
Posts: 242
Registered: ‎03-16-2010
My Device: 9530
Accepted Solution

Problem creating a Deep Round Border !

 

Hi,

 

   I have a FlowFieldManager with 2 fields in it. i want a rounded border around it. I tried with

 

Border border = BorderFactory.createRoundedBorder(new XYEdges(3, 14, 3, 14), Color.WHITE, Border.STYLE_FILLED);
ffm.setBorder(border);

 

With the above code, I get a rounded border, but I want the curve on left & right side to be more round. If I increase the value of left & right i.e. 3, the component in it is not visible properly. Components are layed out using sublayout(), so the width and height of the manager is stable.

 

To solve this problem, I believe I got to use graphics.fillRoundRect(). I tried the following code :

ffm = new FlowFieldManager(VerticalFieldManager.FIELD_HCENTER) {
            protected void paint(Graphics g) {
                g.setBackgroundColor(Color.WHITE);
                g.fillRoundRect(1, 3, getWidth(), getHeight(), 10, 5);
            }
        };
        ffm.add(txt);
        ffm.add(btn);
        add(ffm);

 

With the above code I only see black area in the place of the ffm manager.

 

Can anyone point out where am I going wrong and how to rectify it ?

I am in a hurry to figure out this problem. Any help is appreciated.

 

Thanks

 

 

 


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.
Developer
Posts: 136
Registered: ‎02-01-2009
My Device: Not Specified

Re: Problem creating a Deep Round Border !

You can use an image as border. So while creating the image you can select different specifications for different edges.

Developer
Posts: 147
Registered: ‎08-27-2010
My Device: 9800
My Carrier: airtel

Re: Problem creating a Deep Round Border !

try

g.drawRoundRect instead of  g.fillRoundRect.

Trusted Contributor
Posts: 242
Registered: ‎03-16-2010
My Device: 9530

Re: Problem creating a Deep Round Border !

vivart, drawRoundRect draws the rect of white line, else everything is black.

 

I suceeded drawing the rect using the code :

ffm = new FlowFieldManager(VerticalFieldManager.FIELD_HCENTER) {
            protected void paint(Graphics g) {
                g.setColor(Color.WHITE);
                g.fillRoundRect(1, 1, getWidth(), getHeight(), 24, 24);
            }
        };

 With this also, the components are not visible at all. Same was with drawRoundRect.

 

  How to make the added components (txt and btn) visible ?


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.
Highlighted
Developer
Posts: 147
Registered: ‎08-27-2010
My Device: 9800
My Carrier: airtel

Re: Problem creating a Deep Round Border !

try this

 

 

protected void paint(Graphics g) {
		int oldColor = g.getColor();
		g.setColor(Color.BLUE);
	        g.drawRoundRect(1, 1, getWidth(), getHeight(), 24, 24);
	        g.setColor(oldColor);
	        super.paint(g);
			}

 

 

Trusted Contributor
Posts: 242
Registered: ‎03-16-2010
My Device: 9530

Re: Problem creating a Deep Round Border !

 

Thanks vivart, this worked.

 

Thanks a alot.


--------------------------------------------------------------------------------
For any helpful answers give kudo's (star) to the helper.