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
Posts: 214
Registered: ‎03-18-2012
My Device: 8520
My Carrier: Company
Accepted Solution

problem Border is not Displaying on RightSide

Hi,

       I am creating two LabelField label1 and label2 and then i added border to both of them...and then i added

       thesefields to   HorizontalFieldManager...

     

Problem is that when i use layout methode in LabelField (label1) then border on the Rightside of the LableField(label2) is not displaying...

 

LabelField label1=new LabelField("    IMEI           ")
          {         
              protected void paint(Graphics g)
              {
                  g.setColor(Color.WHITE);
                  super.paint(g);                  
              }             
              protected void layout(int width,int height)
              {
                  super.layout(width, height);
                  setMargin(new XYEdges(0,0,0,50));                  
              }
          };          
          label1.setBackground(BackgroundFactory.createLinearGradientBackground(Color.GREEN,Color.GREEN,Color.GREEN,Color.GREEN));
label1.setBorder(BorderFactory.createBevelBorder(new XYEdges(2,0,2,2)));

 

 LabelField label2=new LabelField("   dasd        ");

label2.setBackground(BackgroundFactory.createLinearGradientBackground(Color.GREEN,Color.GREEN,Color.GREEN,Color.GREEN));
        label2.setBorder(BorderFactory.createBevelBorder(new XYEdges(2,2,2,2)));

 

 HorizontalFieldManager hfm=new HorizontalFieldManager();
      
          hfm.add(label1);
        hfm.add(label2);

Developer
Posts: 19,618
Registered: ‎07-14-2008
My Device: Not Specified

Re: problem Border is not Displaying on RightSide

I'm not sure what is wrong, but you must move this:

setMargin(new XYEdges(0,0,0,50));

out of the layout.  The framework calls layout when it wants to know how much space to allocate to the device.  You have to have set the Margin before then.

 

So take it out of there and do a

label1.setMargin..)

like you set the Border. 

 

I note that your two BorderFactory calls are slightly different.  Is that deliberate?