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
Posts: 17
Registered: ‎08-23-2012
My Device: Bold
My Carrier: Vodafone

Re: how Remove the default focus color from TextSpinBoxField.

Hi All,

 

Please help me,

 

 i want to set different color focus on TextSpinBoxField.

 

thanks in advance. 

Highlighted
Developer
Posts: 107
Registered: ‎05-26-2011
My Device: Torch
My Carrier: Mobilink

Re: how Remove the default focus color from TextSpinBoxField.

you can it thu two ways

1.  override both paint and drawFocus methods in your customlabelfield class shud extends LabelField

 

 

protected void paint(Graphics graphics) {
              
                 setBackground(BackgroundFactory                           .createLinearGradientBackground(Color.WHITE,
                                    Color.WHITE, Color.WHITE, Color.WHITE));
                super.paint(graphics);

       }

   protected void drawFocus(Graphics graphics, boolean on) {
                 setBackground(BackgroundFactory.createLinearGradientBackground(Color.AQUA,
                 Color.AQUA,Color.AQUA,Color.AQUA));

  }

 2.overide just paint method

protected void paint(Graphics graphics) {

                if (isFocus())
                    setBackground(BackgroundFactory
                            .createLinearGradientBackground(Color.AQUA,
                                    Color.AQUA, Color.AQUA, Color.AQUA));
                else
                    setBackground(BackgroundFactory
                            .createLinearGradientBackground(Color.WHITE,
                                    Color.WHITE, Color.WHITE, Color.WHITE));
                super.paint(graphics);

            }

            protected void drawFocus(Graphics graphics, boolean on) {
                 

            }

 hop this help.

Developer
Posts: 17
Registered: ‎08-23-2012
My Device: Bold
My Carrier: Vodafone

Re: how Remove the default focus color from TextSpinBoxField.

Hi Madiha,

that code is working fine for me.

Plz solve my one another problem related TextSpinBoxField

http://supportforums.blackberry.com/t5/Java-Development/how-to-change-text-color-of-TextSpinBoxField...
Developer
Posts: 17
Registered: ‎08-23-2012
My Device: Bold
My Carrier: Vodafone

Re: how Remove the default focus color from TextSpinBoxField.

Hi Madiha,

I am using this code give by you..

in the paint method public will be there


TextSpinBoxField txt=new TextSpinBoxField(choice){
public void paint(Graphics graphics) {
if (isFocus())
setBackground(BackgroundFactory
.createLinearGradientBackground(Color.AQUA,
Color.AQUA, Color.AQUA, Color.AQUA));
else
setBackground(BackgroundFactory
.createLinearGradientBackground(Color.BLACK,
Color.BLACK, Color.BLACK, Color.BLACK));
super.paint(graphics);

}
protected void drawFocus(Graphics graphics, boolean on) {
}
};