Making a context menu look like a pop-up menu in BlackBerry 6

by Retired on ‎07-30-2010 03:50 PM - edited on ‎09-20-2010 05:05 PM by Retired (8,487 Views)



  • BlackBerry® Java® SDK 5.0, 6.0, and later
  • BlackBerry® JDE
  • BlackBerry Java Plug-in for Eclipse®
  • BlackBerry Java Plug-in for Microsoft® Visual Studio®



With BlackBerry® 6, pop-up menus have replaced context menus (or short menus) to allow BlackBerry device users to perform the most common actions for a highlighted item quickly.




The BlackBerry Java SDK 6.0 implementation of pop-up menus uses the new Command Framework API. This API supports defining common functionality once and using it from different parts of your application or from other applications on the BlackBerry device. If you’re not planning on upgrading your application to use the latest BlackBerry APIs, your application’s context menus are converted and displayed as pop-up menus.


Additionally, if your application was built using BlackBerry Java SDK 5.0, by adding an icon to a context menu item, you can easily make your converted context menu look as great as a pop-up menu built using BlackBerry Java SDK 6. In the following code sample, an icon is added to a context menu item. On devices running BlackBerry 6, this icon would be used in the pop-up menu.


import net.rim.device.api.system.Bitmap;

import net.rim.device.api.ui.*;

import net.rim.device.api.ui.component.*;

import net.rim.device.api.ui.container.*;

import net.rim.device.api.ui.image.*;


public class MyMenu extends UiApplication {

    public static void main(String[] args) {

        MyMenu theApp = new MyMenu();



    public MyMenu() {

        pushScreen(new MyMenuScreen());



class MyMenuScreen extends MainScreen {

    public MyMenuScreen() {

        setTitle("Conversion test");


    private MenuItem item1 = new MenuItem("item1", 110, 10) {

        public void run() {




    private MenuItem item2 = new MenuItem("item2", 110, 10) {

        public void run() {




    public void makeMenu(Menu menu, int instance) {

        super.makeMenu(menu, instance);


        Bitmap bitmap = Bitmap.getBitmapResource("my_logo.png");

        Image image = ImageFactory.createImage(bitmap);



        if (instance == Menu.INSTANCE_DEFAULT) {








For more information on creating context menus, see