Update
After receiving more clarification from the OP, I think the answer is correct that you cannot do what they ask ... to create your own menu, but programmatically call MenuItem commands / actions from the built-in menu .
Original answer
If you understood correctly that you want to create your own menu, but you do not want to use the built-in BlackBerry menu, because your menu should look different?
If so, then I would suggest a different approach. I think BlackBerry wants you to do this, it is usually to add MenuItem objects to the built-in menu , but then change the various menu properties in your Screen class makeMenu() method:
protected void makeMenu(Menu menu, int context)
Here are the BlackBerry docs about it , and here is an example that combines adding the menu items that you show above with some changes to the appearance of the menu. I hope you find that this is an easier way to do what you want, which is not related to the need to associate MenuItems with the built-in menu, but yours:
public class MenuScreen extends MainScreen { private Background _menuBackground; private Border _menuBorder; private Font _menuFont; private MenuItem _customMenuItems[]; public MenuScreen() { setTitle("Custom Menu Sample"); getMainManager().setBackground(BackgroundFactory.createSolidBackground(Color.BLACK)); RichTextField f = new RichTextField("Creating a custom menu") { protected void paint(Graphics g) { int oldColor = g.getColor(); g.setColor(Color.WHITE); super.paint(g); g.setColor(oldColor); } }; add(f);
results

Note : if you only need to support OS 6.0 and above, you have other options (let us know). In addition, it is possible that your motivation for writing your own menu is that you want to change the font color, which I donβt think you can do with the code that I show above. Again, if this part of your design, please let us know. Thanks.
source share