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

Posts: 445
Registered: ‎10-14-2008
My Device: Blackberry Bold 9000
My Carrier: SingTel
Accepted Solution

Dynamic LabelField Change Font

How i can change the font of labelfield. i created a class which extends labelfield class and override the sent font method. but its not working. whats problem with this code. please help me out....



import net.rim.device.api.system.Display; import net.rim.device.api.ui.Color; import net.rim.device.api.ui.Font; import net.rim.device.api.ui.FontFamily; import net.rim.device.api.ui.component.LabelField; public class ResponseLabelField extends LabelField{ final FontFamily fontFamily[] = FontFamily.getFontFamilies(); final Font font10 = fontFamily[0].getFont(FontFamily.CBTF_FONT, 8); public ResponseLabelField(String s, long l){ super(s, l); } /* public void setFont(Font font) { font = font10; super.setFont(font); }*/ protected void paintBackground(net.rim.device.api.ui.Graphics g) { g.clear(); g.getColor(); g.setColor(Color.CYAN); g.fillRect(0, 0, Display.getWidth(), Display.getHeight()); g.setColor(Color.BLUE); } public void setFont(Font font) { FontFamily fontFamily[] = FontFamily.getFontFamilies(); font = fontFamily[3].getFont(FontFamily.CBTF_FONT, 14); super.setFont(font); } public void setMargin(int arg0, int arg1, int arg2, int arg3) { // TODO Auto-generated method stub super.setMargin(9, 9, 9, 9); } }




Thanks & Regards
Zahid Naqvi | Senior Software Engineer
Posts: 57
Registered: ‎04-07-2009
My Device: 8300

Re: Dynamic LabelField Change Font

[ Edited ]

Modify your constructor -like this,



public ResponseLabelField(String s, long l){
super(s, l);


 or after creating instance of ResponseLabelField you can call setFont method as it is public.


Message Edited by arif on 05-24-2009 09:17 AM
Posts: 113
Registered: ‎04-09-2009
My Device: Not Specified

Re: Dynamic LabelField Change Font

This is my first ever project developed using RIM Apis. I will try to create a separate project using JDE and let you know how that goes.