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: 17
Registered: ‎06-09-2009
My Device: Not Specified

Issue using the setFont method

Hi All,


I'm trying to set the font of a RichTextField to have a font face: FACE_SYSTEM. The way i found that this can be done is to use a method called 'getFont(int face, int style, int size)', which is part of the javax.microedition.lcdui.Font type.


However, the RichTextField.setFont(font) method does not except the parameter to be of a javax.microedition.lcdui.Font type. It requires the font parameter to be of the net.rim.device.api.ui.Font type. Is there a way that the font face can still be applied to the RichTextField?


any help would be much appreciated.




New Developer
Posts: 20
Registered: ‎09-24-2008
My Device: 9000, 8310, 8520, 9700, 9800, 9500

Re: Issue using the setFont method

to use System font face you can use following


int style =  Font.getDefault().getStyle();





==== to use Bold font




==== to use Normal font 





==== to specify size


 setFont(Font.getDefault().derive(Font.BOLD,size))   //// size in pixels



==== If you want to use some different font face then you can use following code


Font normal_font = Font.getDefault();
        try {
            FontFamily ff = null;
            ff = FontFamily.forName("BBalpha Sans");
            normal_font = ff.getFont(Font.PLAIN, 9);
        } catch (ClassNotFoundException e) {

              /////// Exception handling code

New Developer
Posts: 20
Registered: ‎06-26-2009
My Device: Not Specified

Re: Issue using the setFont method

what I get from your post is that you are mixing J2me api and blackberry api in UI which is not possible its better you stick to blackberry setfont metoh while developing for blackberry.

this might help you


RichTextField rich = new RichTextField();

rich.setFont(Font.getDefault().derive( Font.PLAIN, FieldSize.fontSize));//15