Assuming the actions of your command are different you'll need to
create a new command object for each menu item.  However, you can
create your own Command type, instantiate several slight different
variations, and assign these to your menu items.

Here's an example that won't compile but hopefully gives you an idea:

class MyCommand extends Command {
  private int type;
  public MyCommand(int type) {
    this.type = type;
  }

  public void execute() {
    switch(type):
      case TYPE_1:
      case TYPE_2:
      ...
  }
}

MenuItem item1 = new MenuItem(new MyCommand(TYPE_1);
MenuItem imem2 = new MenuItem(new MyCommand(TYPE_2);

You get the idea ...

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to