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

Posts: 21
Registered: ‎10-09-2008
My Device: Not Specified
Accepted Solution

Get system focus/theme color

[ Edited ]



I want to highlight the text of a CheckboxField with the system focus/highlight/theme color. I know that I could retrieve foreground and background color easily from the Graphics but is there a way to get the system focus/highlight/theme color ?


Today, I have this code but the rendering is quiet ugly (black & white) :


CheckboxField cbField = new CheckboxField("test", true) {
protected void paint(Graphics g) {
if(this.isFocus()) {
int fcolor = g.getColor();
int bcolor = g.getBackgroundColor();
g.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 8, 8);







Message Edited by spiv on 10-28-2008 10:48 AM
BlackBerry Development Advisor
Posts: 15,766
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Get system focus/theme color

These colours are not currently exposed in the BlackBerry API set.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Posts: 21
Registered: ‎10-09-2008
My Device: Not Specified

Re: Get system focus/theme color

It's a pitty Smiley Wink



New Developer
Posts: 2
Registered: ‎02-26-2009
My Device: Curve 8900

Re: Get system focus/theme color

I'm aware that I'm a tad behind the times... Anyway I was searching relentlessly to find a way to get the theme highlight color for my application, anddd I came up with this (after I gave up on googling and started looking through the api documentation):


protected final void drawHighlightRegion(Graphics graphics,
                                         int style,
                                         boolean on,
                                         int x,
                                         int y,
                                         int width,
                                         int height)


I noticed in your code that you're trying to draw a rounded highlight region, so this wouldn't directly help obviously, but don't forget you can always draw over it (aka maybe draw the background over the circle-ness on each side.


Anyway hope I helped, I found your post during my googling-ness a few days ago, so I figured I'd go back and reply.

Posts: 15
Registered: ‎09-06-2010
My Device: Not Specified

Re: Get system focus/theme color

So is there a work-around way to getting these colors?