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
patilajayr
Posts: 414
Registered: ‎07-28-2010
My Device: 8000

how we set color to LabelField??

 

     Hello friends,

                      here i  am create 5 labelfield i want to give color to that labelfield. tell me how to give color to that lable field???

 

here is my code

 

 

LabelField lbl1,lbl2,lbl3,lbl4,lbl5; 
ANULOMA_VILOMA()
{

lbl1=new LabelField("Step 1: Sit comfortably with back straight and hands resting on your knees.");

lbl2=new LabelField("step2: Bend the forefinger and middle finger of your right hand.");

lbl3=new LabelField("step3: place the thumb on the right nostril and press the ring finger on the left nostril.Breathe in through the right nostril closing the left.");
lbl4=new LabelField("step4: hold breath closing both nostrils.");

lbl5=new LabelField("step 5:Place the ring finger on the left nostril and press the right nostril with the thumb. Exhale through the left nostril.");


      
}		

 how should i give color to that labelField??

 

Thanks and Regards,

      Ajay Patil.

 

Please use plain text.
Developer
vivart
Posts: 147
Registered: ‎08-27-2010
My Device: 9800

Re: how we set color to LabelField??

 

LabelField lbl = new LabelField("color");
		lbl.setBackground(BackgroundFactory.createSolidBackground(Color.RED));

 

 

 

Please use plain text.
Developer
patilajayr
Posts: 414
Registered: ‎07-28-2010
My Device: 8000

Re: how we set color to LabelField??

Hello,

          This is not work. i am using os 4.5 in that when i create that it will ask to create backgoundfactry class or interface. what should i do for that??

 

thanks 

ajay

Please use plain text.
Developer
ibarrera
Posts: 588
Registered: ‎05-29-2009
My Device: 9100

Re: how we set color to LabelField??

You need to override paint method in your labelfield...

 

protected void paint(Graphics graphics){

  graphics.setBackgroundColor(_backgroundColor);

   super.paint(); 

}

 

Please use plain text.
Developer
vivart
Posts: 147
Registered: ‎08-27-2010
My Device: 9800

Re: how we set color to LabelField??

  is right but you have to call graphics.clear() also.

 

LabelField lbl = new LabelField("color"){
			protected void paint(Graphics g) {
				g.setBackgroundColor(Color.RED);
				g.clear();
				super.paint(g);
			}
		};

 

 

 

Please use plain text.
Developer
patilajayr
Posts: 414
Registered: ‎07-28-2010
My Device: 8000

Re: how we set color to LabelField??

Thanks for that it works. but at backgroud i used image. when i place that label field on image. that lable fild part show white. i want only worlds are show on that image. what should i do for that??

 

 

lbl1=new LabelField("Step 1: Sit comfortably with back straight and hands resting on your knees."){
			protected void paint(Graphics g) {
				g.setColor(13559791);
				g.clear();
				super.paint(g);
			}
		};

  thanks

ajay

 

Please use plain text.