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
Angel007
Posts: 22
Registered: ‎01-19-2009
My Device: Not Specified

How to change the font color of the label in the BasicEditField???

Hi!,

 

I need to change the font color of the label in the BasicEditField without affect the color of the rest of the text in same field, like this example. Someone know how to make this?. Thanks

 

CustomEditField

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to change the font color of the label in the BasicEditField???

I thinik the quickest way is to have a separate LabelField for the label, then define the BasicEditField without the label.

 

Place both fields in a HorizontalFieldManager, then add this manager to your screen.

 

 

 

Please use plain text.
Developer
Angel007
Posts: 22
Registered: ‎01-19-2009
My Device: Not Specified

Re: How to change the font color of the label in the BasicEditField???

But when the text is longer than one line I want the BasicEditField looks like this one:

 

Books

 

And if I use a LabelField and a BasicEditField, how can I program the BasicEditField with one offset in the first line for don't overlay the LabelField  with the first line of the BasicEditField????

Please use plain text.
Developer
marcn
Posts: 53
Registered: ‎01-08-2009
My Device: Not Specified

Re: How to change the font color of the label in the BasicEditField???

You could try a FlowFieldManager instead of HorizontalFieldManager.

 

Please use plain text.
Developer
marcn
Posts: 53
Registered: ‎01-08-2009
My Device: Not Specified

Re: How to change the font color of the label in the BasicEditField???

As I posted that last response I realized that it probably wouldn't work because the BaseEditField is just a single field and the FlowFieldManager is more for controlling the flow of multiple individual fields.
Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to change the font color of the label in the BasicEditField???

No, this is two fields: a LabelField and an EditField.

 

FlowManager will work, provided that you keep the LabelField from claimimg the entire width of the display. Otherwise, the edit field will be on the next line.

 

 

 

Please use plain text.
Developer
Angel007
Posts: 22
Registered: ‎01-19-2009
My Device: Not Specified

Re: How to change the font color of the label in the BasicEditField???

It doesn't work as I want, because the BasicEditField have a rectangle form and it will happend:

 

______________________________________________

|FlowFieldManager                                                     |

|__________     _______________________________  |

|LabelField  |    | BasicEditField                                |  |

|_________ |    |                                                      |  |

|                      |                                                      | |

|                      |_______________________________| |

|_____________________________________________|

 

Separating the field in two new fields as a LabelField and a BasicEditField is not the better solution. I need only to change the color of the Label in a BasicEdiField, and may be there is a solution for make this...

Please use plain text.
Developer
Rajat_10Sep
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: How to change the font color of the label in the BasicEditField???

Hi,

 

Please try this code and let me know if this is helpful or not

 

 

HorizontalFieldManager managerHorz = new HorizontalFieldManager();
VerticalFieldManager managerVert1 = new VerticalFieldManager();
VerticalFieldManager managerVert2 = new VerticalFieldManager(); 

 

LabelField objLabel = new LabelField("ORANGE"){
             public void paint(Graphics g){
                    g.setColor(Color.RED);
                    super.paint(g);
                }
          };
       managerVert1.add(objLabel);
     
      BasicEditField objBasic = new BasicEditField();
      managerVert2.add(objBasic);
     
      managerHorz.add(managerVert1);
      managerHorz.add(managerVert2);
     
      add(managerHorz);

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to change the font color of the label in the BasicEditField???

I believe Angel007 is correct, the BascEditField will not flow under the LabelField, even with Rajat's code.  Fields in Blackberry UI are rectangular.

 

Angel007 - is the Field you are displaying UpdateAble?  In other words, will people be changing the contents?

Please use plain text.
Developer
Rajat_10Sep
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: How to change the font color of the label in the BasicEditField???

Hi,

 

Then I think you should you this , it will help you in differentiating between your label text and textField text.

 

public ActiveRichTextField(String text,
                           int[] offsets,
                           byte[] attributes,
                           Font[] fonts,
                           int[] foregroundColors,
                           int[] backgroundColors,
                           long style)
Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Please use plain text.