No, but you can do something close:
m.addItem("Login", new MenuCmd(1));
m.addItem("Logout", new MenuCmd(2));
class MenuCmd implements Cmd
{
private int whichCmd;
public MenuCmd(int which) {whichCmd = which;}
public execute()
{
switch(whichCmd)...
}
}
On May 29, 8:08 am, Magnus <[email protected]> wrote:
> Hi,
>
> I would like to give all my menu items the same command object:
>
> m.addItem ("Login", cmd);
> m.addItem ("Logout", cmd);
> m.addItem ("Register",cmd);
> ...
>
> Is it possible to retrieve the selected menu item within the command
> object's method "execute"?
>
> The reason is that I want to keep my code compact, i. e. using a
> single method that reacts on menu item selections and distinguishes
> the items with a select statement...
>
> Many thanks
> Magnus
--
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.