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
QuestionMan
Posts: 167
Registered: ‎06-30-2011
My Device: n/a
My Carrier: Koodo
Accepted Solution

LabelField font and color?

If I had a simple line like this, how could I make the font and/or color change in the simplest way?

 

LabelField title = new LabelField(" Howdie ", LabelField.USE_ALL_WIDTH|DrawStyle.HCENTER);

 

Also, it is the same for buttons?

 

Thanks!!!

Please use plain text.
Contributor
Remilito
Posts: 26
Registered: ‎05-26-2011
My Device: TORCH 9800
My Carrier: T Mobile

Re: LabelField font and color?

I think this simple code answers your question:

LabelField lb = new LabelField("sample"){
			protected void paint(Graphics graphics)  
		    {  
				
				graphics.setBackgroundColor(Color.BLUE);
				graphics.fillRect(0,0,getWidth(),getHeight());
				graphics.setColor(Color.RED); 
				graphics.clear();
				super.paint(graphics);
				
		     
		    }  
			
		};
		lb.setFont(Font.getDefault().derive(Font.ITALIC));
		this.add(lb);

 

Please use plain text.
Contributor
Remilito
Posts: 26
Registered: ‎05-26-2011
My Device: TORCH 9800
My Carrier: T Mobile

Re: LabelField font and color?

Oh and for the button you can do the same idea ( overriding paint method) and you can also take a look at Ben's good work on Custom Button Field : http://www.coderholic.com/blackberry-custom-button-field/. 

 

Hope this helps!

Please use plain text.