pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject Re: Menus??
Date Thu, 30 Jul 2009 06:28:49 GMT
On Thu, Jul 30, 2009 at 1:52 PM, Niclas Hedhman<niclas@hedhman.org> wrote:
> No tutorial on menus, no demo code, and a dumb developer who can't
> figure out how to get a standard MenuBar in a Frame....

Ok, I finally figured it out by going thru heaps of code, so if
someone else comes across this later;

1. Create a MenuBar

2. Create a MenuBar.Item (mbItem), which may either take a String,
Image or ButtonData instance in the constructor.

3. Create a Menu (menu).

4. call mbItem.setMenu( menu );

5. Create a Menu.Section and give it a name (probably optional).

6. Add the section to the menu.getSections() sequence.

7. Create a Menu.Item (mItem), which again can take a String, Image or
ButtonData/MenuItemData instance.

8. Add the mItem to the Section.

9. Place the MenuBar in the Frame or Layout where needed.


The following code snippet is my working test copy;

        MenuBar bar = new MenuBar();
        MenuBar.Item mbItem = new MenuBar.Item( "File" );
        Menu menu = new Menu();
        mbItem.setMenu( menu );
        Menu.Item item = new Menu.Item( "Open...");
        Menu.SectionSequence sections = menu.getSections();
        Menu.Section section = new Menu.Section();
        section.setName( "default" );
        sections.add( section );
        section.add( item );
        bar.getItems().add( mbItem );
        Frame frame = new Frame("Menus", bar);
        frame.open( display );


Cheers
-- 
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

I  live here; http://tinyurl.com/2qq9er
I  work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug

Mime
View raw message