Unfortunately, the tutorial is still missing a lot of information, including menu docs. However, it looks like you managed to figure it out.

Until we are able to find time to improve the tutorials (and, believe me, this is consistently at the top of my to-do list), you may find the WTKX Primer useful. It explains exactly how WTKX maps to Java, so, when you see an example that is written in WTKX (e.g. Kitchen Sink app), you will be able to tell what the corresponding Java should look like.

The primer is in the tutorials/www directory. If you run the deploy target, it will be in the root of pivot_tutorials.war as wtkx_primer.html.


On Jul 30, 2009, at 2:28 AM, Niclas Hedhman wrote:

On Thu, Jul 30, 2009 at 1:52 PM, Niclas Hedhman<[email protected]> 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

Reply via email to