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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums on April 1st. BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Posts: 46
Registered: ‎07-12-2008
My Device: Not Specified

Custom Menu Drawing

I'm able to specify a global font for my application by using the Font.setDefault static method.  This will set the font for static menu items, but when a menu item is highlighted, the font that is used is the current theme font, and the highlight color is from the current theme.


I would like to find a way to customize the menu's so that my application can have full control over their appearance.  Has anyone does this type of thing before? 


I've downloaded a couple apps off the internet (ATT GPS navigator is one)....and it seems to suffer the same thing I'm seeing.  It uses a specific font for everything, but the menu's are still tied to the theme.


Our app will run on many devices, but the current one I'm using is an ATT Curve 8310.  Our app is built against the 4.2.1 RIM libraries.



Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: Custom Menu Drawing

The way I did it (if I ever write an autobiography I'm calling it that) is by catching the menu key keydown event and then invoking my menu, eg:


protected boolean keyDown(int keycode, int time) { if (Keypad.key(keycode) == Keypad.KEY_MENU) { displayMenu(); return true; } return super.keyDown(keycode, time); }


Then, displayMenu creates an instance of my own MenuScreen class and pushes it onto the display stack, as in the following:



private void displayMenu() { menu = makeMenu(); MenuScreen menuScreen = new MenuScreen(menu); UiApplication.getUiApplication().pushScreen(menuScreen); }


makeMenu is where the menu is created and populated:


private Menu makeMenu() { menu = new Menu(); SubMenu newSubMenu = menu.addSubMenu("New"); newSubMenu.add("A New Thing", Config.toolbarShortcutAccelerator).setRunnable(new Runnable() { public void run() { addNewToolbarAction(); } });





menu.add("About", Config.appInfoAccelerator).setRunnable(new Runnable() {

public void run() {






  And so, for something like this you'd need to create a MenuScreen class (an extension of Screen that's responsible for drawng the menu frame) and Menu which, in my impl, is a VerticalFieldManager which acts as the model and is responsible for drawing the menu items.


  Beyond that, I also have code which iterates down through the display stack and checks each Manager to see if it's an instance of IMenuContributor (my own interface).  If it is then its "makeContextMenu" (parameterized against my own Menu rather than the stock one) is called in order to allow for context menu items.


  It's not the most trivial (or well-architected) approach, but it works for me.  I would release this to the public but right now it's a bit messy and is part of a larger framework that I use for UI operations (for tooltips, autocomplete fields, etc).  Anyway, hope it gives you some ideas.

Posts: 46
Registered: ‎07-12-2008
My Device: Not Specified

Re: Custom Menu Drawing

[ Edited ]
Thanks for the advice!  I was hoping I wouldn't have to go to the trouble of implementing the whole menu myself, but I'm guessing from the lack of comments on the thread and your solution are indicators there is no easy way to just override the built in menu's.
Message Edited by ryandevore on 09-07-2008 03:46 PM
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Custom Menu Drawing

The standard answer from Rim to this question is that the menu fonts are tied to the theme.  So Richard's idea, which is very impressive, or doing something very similar, does seem to be the only option.

Posts: 25
Registered: ‎09-08-2008
My Device: Not Specified

Re: Custom Menu Drawing

Hi Richard_Puckett,


Iam very new to this domain. I have to create a tooltip for images means when i focus on image(BitmapField) it should show tooltip.  In this thread you mentioned your having your own customized Tooltip component.  please send sample code for creating tooltip for BitmapField. Or else if you know any article please send it to me. 


Thanks in advance.


Below code iam using for creating BitmapField.


BitmapField bmf_temp = new BitmapField(bitmap_temp, BitmapField.FOCUSABLE) { private XYRect xyrect=new XYRect(); protected boolean navigationClick(int status, int time) { System.out.println("!!!!!!!!!!!!!!!!Inside NavigationClick :: URL !!!!!!!!!!!"+info.getDataUrl()); PrimaryResourceFetchThread thread = new PrimaryResourceFetchThread("http://"+info.getDataUrl(), null, null, null,application_temp); if(thread.isAlive()==false) { thread.start(); } return true; } public void paint( Graphics graphics ) { graphics.setColor(Color.GRAY); graphics.drawRect(0,0,getWidth(),getHeight()); super.paint(graphics); } };


New Contributor
Posts: 2
Registered: ‎06-03-2010
My Device: none
My Carrier: student

Re: Custom Menu Drawing



I have the same urgent problem to build a custom menu. I am very new to BB development environment, only one week.


Can you please share all your code with me? no metter how much messy it is.


Thank you very much.

Posts: 23
Registered: ‎05-27-2011
My Device: 9700
My Carrier: Digicel

Re: Custom Menu Drawing

thank u this helped richard_puckett