Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 684409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:48:49+00:00 2026-05-14T01:48:49+00:00

i want to create sub menu for a BB application when i click on

  • 0

i want to create sub menu for a BB application
when i click on menu item it shows

Option 1
Option 2
Option 3

When i click on option 3 it should display

1
2
3

as sub menu items..

using j2me + eclipse

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:48:49+00:00Added an answer on May 14, 2026 at 1:48 am

    Always wanted to do this )
    alt text http://img380.imageshack.us/img380/3874/menugy.jpg

    class Scr extends MainScreen {
        SubMenu menu = new SubMenu();
    
        public Scr() {
    
            for (int i = 0; i < 3; i++) {
                SubMenu sMenu = new SubMenu();
                menu.add(new SubMenuItem(i + " item", sMenu));
                for (int k = 0; k < 3; k++) {
                    SubMenu sSMenu = new SubMenu();
                    sMenu.add(new SubMenuItem(i + "-" + k + " item", sSMenu));
                    for (int l = 0; l < 3; l++) {
                        sSMenu
                                .add(new SubMenuItem(i + "-" + k + "-" + l
                                        + " item"));
                    }
                }
            }
    
            add(new LabelField("testing menu", FOCUSABLE) {
                protected void makeContextMenu(ContextMenu contextMenu) {
                    menu.mRectangle.x = this.getContentRect().X2();
                    menu.mRectangle.y = this.getContentRect().Y2();
                    Ui.getUiEngine().pushScreen(menu);
    
                    EventInjector.invokeEvent(new KeyEvent(KeyEvent.KEY_DOWN,
                            Characters.ESCAPE, 0));
                }
            });
        }
    }
    
    class SubMenu extends PopupScreen implements ListFieldCallback {
        private static final int MAX_WIDTH = Font.getDefault().getAdvance(
                "max menu item text");
        XYRect mRectangle = new XYRect();
        Vector mSubMenuItems = new Vector();
        ListField mListField;
    
        public SubMenu() {
            super(new SubMenuItemManager(), DEFAULT_CLOSE);
            int rowHeight = getFont().getHeight() + 2;
            mListField = new ListField() {
                protected boolean navigationClick(int status, int time) {
                    runMenuItem(getSelectedIndex());
                    return super.navigationClick(status, time);
                }
            };
            mListField.setRowHeight(rowHeight);
            add(mListField);
            mListField.setCallback(this);
            updateMenuItems();
        }
    
        public void add(SubMenuItem subMenuItem) {
            mSubMenuItems.addElement(subMenuItem);
            subMenuItem.mMenu = this;
            updateMenuItems();
        }
    
        private void updateMenuItems() {
            int rowCounts = mSubMenuItems.size();
            mRectangle.width = getMaxObjectToStringWidth(mSubMenuItems);
            mRectangle.height = mListField.getRowHeight() * rowCounts;
            mListField.setSize(rowCounts);
        }
    
        private void runMenuItem(int index) {
            SubMenuItem item = (SubMenuItem) get(mListField, index);
            if (null != item.mSubMenu) {
                item.mSubMenu.setSubMenuPosition(getSubMenuRect(index));
                Ui.getUiEngine().pushScreen(item.mSubMenu);
            } else {
                item.run();
            }
        }
    
        private XYRect getSubMenuRect(int index) {
            SubMenuItem item = (SubMenuItem) get(mListField, index);
            XYRect result = item.mSubMenu.mRectangle;
            result.x = mRectangle.x + mRectangle.width;
            result.y = mRectangle.y + mListField.getRowHeight() * index;
            int testWidth = Display.getWidth() - (mRectangle.width + mRectangle.x);
            if (testWidth < result.width) {
                result.width = testWidth;
            }
    
            int testHeight = Display.getHeight()
                    - (mRectangle.height + mRectangle.y);
            if (testHeight < result.height)
                result.height = testHeight;
    
            return result;
        }
    
        public void setSubMenuPosition(XYRect rect) {
            mRectangle = rect;
        }
    
        protected void sublayout(int width, int height) {
            super.sublayout(mRectangle.width, mRectangle.height);
            setPosition(mRectangle.x, mRectangle.y);
            setExtent(mRectangle.width, mRectangle.height);
        }
    
        private int getMaxObjectToStringWidth(Vector objects) {
            int result = 0;
            for (int i = 0; i < objects.size(); i++) {
                int width = getFont().getAdvance(objects.elementAt(i).toString());
                if (width > result) {
                    if (width > MAX_WIDTH) {
                        result = MAX_WIDTH;
                        break;
                    } else {
                        result = width;
                    }
                }
            }
            return result;
        }
    
        public void drawListRow(ListField field, Graphics g, int i, int y, int w) {
            // Draw the text.
            String text = get(field, i).toString();
            g.setColor(Color.WHITE);
            g.drawText(text, 0, y, DrawStyle.ELLIPSIS, w);
        }
    
        public Object get(ListField listField, int index) {
            return mSubMenuItems.elementAt(index);
        }
    
        public int getPreferredWidth(ListField listField) {
            return mRectangle.width;
        }
    
        public int indexOfList(ListField listField, String prefix, int start) {
            return 0;
        }
    }
    
    class SubMenuItemManager extends VerticalFieldManager {
        public SubMenuItemManager() {
            super(USE_ALL_HEIGHT | USE_ALL_WIDTH);
        }
    
        public int getPreferredWidth() {
            return ((SubMenu) getScreen()).mRectangle.width;
        }
    
        public int getPreferredHeight() {
            return ((SubMenu) getScreen()).mRectangle.height;
        }
    
        protected void sublayout(int maxWidth, int maxHeight) {
            maxWidth = getPreferredWidth();
            maxHeight = getPreferredHeight();
            super.sublayout(maxWidth, maxHeight);
            setExtent(maxWidth, maxHeight);
        }
    
    }
    
    class SubMenuItem implements Runnable {
        String mName;
        SubMenu mMenu;
        SubMenu mSubMenu;
    
        public SubMenuItem(String name) {
            this(name, null);
        }
    
        public SubMenuItem(String name, SubMenu subMenu) {
            mName = name;
            mSubMenu = subMenu;
        }
    
        public String toString() {
            return mName;
        }
    
        public void run() {
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 387k
  • Answers 387k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need at least a small Objective C stub to… May 15, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer template<class T> void f(T, typename size_map<sizeof(&U::foo)>::type* = 0); This doesn't… May 15, 2026 at 12:15 am
  • Editorial Team
    Editorial Team added an answer No, a reliable session will time out just like any… May 15, 2026 at 12:15 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.