开发者

BlackBerry RichTextField change font

I wo开发者_如何学运维uld like to change the font of a RichTextField but I want to change it after the initialization of the Field.

Is it possible?


Font font = Font.getDefault() ;
FontFamily ff;
try 
{
    ff = FontFamily.forName("arial");
    font = ff.getFont(FontFamily.SCALABLE_FONT, 18).derive(Font.BOLD);
    field.setFont(font);
} 
catch(ClassNotFoundException e) 
{

}


If you can obtain the reference to the RichTextField, you can call setFont(Font font) on it, and then call invalidate() to force the field to repaint itself. invalidate() is a protected method, so you're going to have to modify your RichTextField class (extend it) to either update setFont to automatically call invalidate, or provide a public version of invalidate that you can call.


other way...

try {
            myFontFamily = FontFamily.forName("BBAlpha Serif");
            Font appFont = myFontFamily.getFont(Font.PLAIN, 6, Ui.UNITS_pt);
            field.setFont(appFont );

        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜