Programmatically display a sub-menu

Is it possible to programmatically display a sub-menu, as I am looking to dynamically populate a sub-menu and then display it?

e.g.

private Command populateMenu = new Command() {
		
    public void menuSelected(MenuItem selectedItem) {
        for (int i = 0; i < 5; ++i) {
            selectedItem.addItem(("item " + i), null);
        }
        selectedItem.setCommand(null);

        // how do I display the new sub-menu? 
    }
};