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
New Developer
chenry1124
Posts: 12
Registered: ‎06-03-2009
My Device: Not Specified

TextSpinBoxField color

Is there a way to change the color of the TextSpinBoxField from the default blue?  I have tried setBackground, but it seems to have no effect.  

 

I have also tried overriding the paint method in a custom class based on the TextSpinBoxField, but oddly, the graphics object provided only gives access to the spinning portion of the field.  The left and right margins are not included.

Please use plain text.
Developer
BB-Dude
Posts: 516
Registered: ‎07-23-2010
My Device: 9900

Re: TextSpinBoxField color

Try overriding the setBackground method if you are using 4.6 OS and later.

Please use plain text.
New Developer
chenry1124
Posts: 12
Registered: ‎06-03-2009
My Device: Not Specified

Re: TextSpinBoxField color

setBackground is final in Field, so it cannot be overridden.

 

Here is what I tried earlier, just as a test - it seemed to have no effect:

 

mySpin.setBackground(BackgroundFactory.createSolidBackground(Color.GREEN));

Please use plain text.
Developer
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Re: TextSpinBoxField color

The margins are never included in the Graphics object (nor Field's extent). A Field can never paint anything on its margins - they are there for the parent manager to decide how to position the Field properly. Don't forget that margins of different Fields may (and, in native BlackBerry gadgets, do) actually overlap.

 

It is the same way on the Web - your background color or image stretches all the way to the outer border boundary but not to the margins.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
New Developer
chenry1124
Posts: 12
Registered: ‎06-03-2009
My Device: Not Specified

Re: TextSpinBoxField color

"Margins" was a poor choice of words.  The TextSpinBoxField displays what looks like a button with the selected text displayed on it.  The other visible rows are displayed in a rectangle that extends above and below the button.  Normally this rectangle appears to be behind the button, and the button is wider than the rectangle.  When I override paint, it only gives access to the rectangle - the wider parts of the button are unaffected, and the button then appears to be behind the rectangle.

Please use plain text.
Developer
pradeep_ch
Posts: 543
Registered: ‎12-23-2010
My Device: Z10

Re: TextSpinBoxField color

try this in spinboxfield drawfocus method

 

 protected void drawFocus(Graphics g, boolean on)
            {
                XYRect rect = new XYRect();
                getFocusRect(rect);
                drawHighlightRegion(g, HIGHLIGHT_FOCUS, false, rect.x, rect.y, rect.width, rect.height);
            }

Please use plain text.
Developer
BrajeshSanodiya
Posts: 134
Registered: ‎08-03-2011
My Device: torch, Z10

Re: TextSpinBoxField color

override the draw focus
TextSpinBoxField txtSpin=new TextSpinBoxField(/*String array*/){
protected void drawFocus(Graphics graphics, boolean on) {
}
};

it will hide the blue background... if u want to be change background the TextSpinBoxField the inside use this method..

TextSpinBoxField txtSpin=new TextSpinBoxField(/*String Array*/){
protected void drawFocus(Graphics graphics, boolean on) {
graphics.setColor(Color.GRAY);
}
};
-----------------------------------------------------------------------
"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
-----------------------------------------------------------------------
Please use plain text.