Welcome!

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

Reply
Developer
zac_mathews
Posts: 31
Registered: ‎08-07-2008
My Device: Not Specified

How to change Text Color of all Fields on a MainScreen?...

Hi

Actually my problem is I have set MainScreen Background to a very dark Color (BLACK) and I cannot see any of the text  of any fields displayed on the screen. (By default all text is displayed in black in color) Is there any way to set Text Color of all Fields (ButonField, BasicEditField, LabelField ....etc) to White or any other Color With out changing Theme.

 

One way I found is to extend each Field class and override paint as shown below.

 

.


 

 

class MyXXXField extends XXXField{

public MyXXXField(String string, boolean b) {

         super(string, b);

}

 

protected void paint(Graphics g) {

     g.setColor(COLOR);

     super.paint(g);

}

};


 

 

Is there is any alternative?....

Thanks in Advance..

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to change Text Color of all Fields on a MainScreen?...

i would do it the same way. create extensions of the fields you use and use them instead.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
zac_mathews
Posts: 31
Registered: ‎08-07-2008
My Device: Not Specified

Re: How to change Text Color of all Fields on a MainScreen?...

Thank you Simon for your reply,

 I just want to know is there any other Simple way to do this instead of extending each and every field class and overriding  paint ?....

Thanks in Advance....

Developer
belberry
Posts: 265
Registered: ‎08-27-2009
My Device: Not Specified

Re: How to change Text Color of all Fields on a MainScreen?...

You can see the following custom code for labelFiled and Color to it...

import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.*;

public class CLabel extends LabelField
{
    int col = Color.BLUE;
    public CLabel() 
    {    
    }
    
    public CLabel(String text,long style)
    {
        super(text,style);
    }
    
    public CLabel(String text)
    {
        super(text);
    }
    
    public void setColor(int col)
    {
        this.col = col;
    }
    
    
    
  protected void paintBackground(Graphics g) 
    {       
          g.setColor(col);        
    } 
} 

 

Developer
zac_mathews
Posts: 31
Registered: ‎08-07-2008
My Device: Not Specified

Re: How to change Text Color of all Fields on a MainScreen?...

Thanks mate for your reply...

Actually do you know any way that we can change Text Color of ALL TYPES OF FIELDS without extending them?...

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to change Text Color of all Fields on a MainScreen?...

Sorry ZAC, I am not aware of doing this for all Fields, except by setting a theme for the device.  I think you will have to extend the Fields used in your application.

 

You probably have to do this anyway.  Imagine if you set your Font to display Blue, then a user set their theme to have a Blue Background.  Your Fields will become invisible (or at best difficult to read). 

Developer
swap_chau
Posts: 179
Registered: ‎06-15-2011
My Device: Storm 9550

Re: How to change Text Color of all Fields on a MainScreen?...

Add a VerticalFieldManager to MainScreen. Instead of adding to default manager, add your fields to this VerticalFieldManager. Set the forecolor by overriding paint method of above vertical field manager as shown below. protected void paint(Graphics g)

{

g.setColor(_foreColor);

super.paint(g);

}

 

Whenever you add any field to this manager, the field will inherit color from above mentioned manager.