3

I am developing a blackberry app and I am new to Blackberry. I am using Label Field in every screens, but there is a color surrounding the LabelField other than the background I have given for the screen like the image I have given here..

enter image description here

This is a header in my App,which comes in every screens. Here you can see a white color around the "state editions". It does not look good. I want the orange background color at the place of white color. Thanks in advance...

Aju
  • 4,597
  • 7
  • 35
  • 58
  • Will you please post the code segment you use for the LabelField, normally it doesn't have any background (no white), and it has transpasernt background. Did you set any background for it via setBackground(params)? – Rupak Jan 26 '12 at 11:43
  • Ignore previous comment - Will you please post the code segment you use for the LabelField, normally it doesn't have any background color. Did you set any background for it via setBackground(params)? – Rupak Jan 26 '12 at 11:50
  • lF1= new LabelField("state editions",LabelField.FIELD_LEFT |FIELD_VCENTER) { public void paint(Graphics graphics) { graphics.clear(); graphics.setColor(Color.BLACK); graphics.setBackgroundColor(Color.ORANGE); graphics.fillRect(0, 0,0, 0); super.paint(graphics); } }; – Aju Jan 26 '12 at 11:53
  • I have posted my comment in Answer (for long text). – Rupak Jan 26 '12 at 11:58

1 Answers1

3

You are using the following code.. (from your comment)

lF1= new LabelField("state editions",LabelField.FIELD_LEFT |FIELD_VCENTER) {
    public void paint(Graphics graphics) { 
        graphics.clear();
        graphics.setColor(Color.BLACK); 
        graphics.setBackgroundColor(Color.ORANGE); graphics.fillRect(0, 0,0, 0); 
        super.paint(graphics); 
    } 
}; 

Try to modify this like the following:

lF1= new LabelField("state editions",LabelField.FIELD_LEFT |FIELD_VCENTER) {
    public void paint(Graphics graphics) {             
        super.paint(graphics); 
    } 
}; 

That means, you don't have to extend default LabelField.

Just use,

lF1= new LabelField("state editions",LabelField.FIELD_LEFT |FIELD_VCENTER);

And check the Graphics , graphics.clear() etc in the API.

Rupak
  • 3,674
  • 15
  • 23
  • Use `lF1.setFont(desiredFont)`. Changing font color requires extending `LabelField`. You just have to add `graphics.setColor(desiredColor)` before calling `super.paint(graphics)`. – Rupak Jan 26 '12 at 12:14