黑莓中的自定义菜单 - 更改菜单项的字体颜色

时间:2012-03-16 10:37:50

标签: blackberry menuitem blackberry-eclipse-plugin

我在我的应用程序中创建了custom menu,我已经在菜单中设置了background,border and font项目显示。但我无法为菜单中的菜单项显示设置font color 如何设置菜单项的字体颜色?? .. 我的代码看起来像这样:
我设置了边框,背景和字体,如下所示: -

XYEdges edge = new XYEdges(10, 10, 10, 10);
menu_border = BorderFactory.createRoundedBorder(edge,Border.STYLE_DOTTED);
menu_back = BackgroundFactory.createSolidTransparentBackground(Color.LIGHTPINK,50);
    try 
    {
        FontFamily fnt_family = FontFamily.forName("BBCasual");
        menu_font = fnt_family.getFont(Font.PLAIN,30,Ui.UNITS_px);
    }
    catch(ClassNotFoundException e){
    }

我重写了makeMenu()函数,如下所示:

protected void  makeMenu(Menu menu,int context) 
{
    menu.setBackground(menu_back);
    menu.setBorder(menu_border);
    menu.setFont(menu_font);
    super.makeMenu(menu, context);
}

提前致谢..

2 个答案:

答案 0 :(得分:3)

没有API可以做你想做的事。

答案 1 :(得分:-1)

LabelField label0=new LabelField(" Label",LabelField.USE_ALL_WIDTH){

     public void paint(Graphics g)
     {                                   
          g.setColor(Color.RED);
          super.paint(g);
     }   
};

此代码将labelfield的字体颜色设置为红色,将其用于菜单并根据需要更改颜色

相关问题