views:

35

answers:

0

Hi

I am trying to change Font color and Font size at runtime of my Field ColorLabelField which extends LabelField. Following is a code :

public class ColorLabelField extends LabelField 
{
    private int _newcolor = Color.BLACK;
    private Font _font = Font.getDefault();

    public ColorLabelField(String label) 
    {
        super(label);
    }

    protected void paint(Graphics graphics) 
    {
        graphics.setColor(this._newcolor);
        graphics.setFont(_font);
        super.paint(graphics);
    }

    public void setColor(int newcolor) 
    {
        this._newcolor = newcolor;
        Graphics g = UiApplication.getUiApplication().getActiveScreen().getGraphics();
        this.paint(g);
    }

    public void setFont(Font newFont) 
    {
        this._font = newFont;
        Graphics g = UiApplication.getUiApplication().getActiveScreen().getGraphics();
        this.paint(g);
    }

Now I am trying following code :

    Font font_date = fontFamily[0].getFont(FontFamily.SCALABLE_FONT, 8);    
    ColorLabelField label = new ColorLabelField("SYS");
    ColorLabelField label.setColor(Color.ORANGE);
    ColorLabelField label.setFont(font);

I was able to change color of the font but i was NOT able to change font size.

When I tried setApplicationFont method of FontManager, I was able to change Font, but, It sets font of all labels. I was unable to control invidual font size.

Thanks & Regards.