> > i declare my Applet class "extends Applet implements ActionListener
> > {.." as i did with my former JFrame class, create my menu as usual and
[quoted text clipped - 5 lines]
> addActionListener(this) on them to register your applet class as the
> actionlistener for these menu options.
i did it, my code for one item for example looks like that:
JMenuItem menuItem = new JMenuItem("Cancel");
menuItem.setMnemonic(KeyEvent.VK_C);
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
ActionEvent.ALT_MASK));
menuItem.setActionCommand("cancel");
menuItem.addActionListener(this);
menu.add(menuItem);
thank you for the answer anyway! maybe there is something else i missed...
Luc Van Bogaert - 30 Nov 2003 12:47 GMT
> JMenuItem menuItem = new JMenuItem("Cancel");
> menuItem.setMnemonic(KeyEvent.VK_C);
[quoted text clipped - 5 lines]
>
> thank you for the answer anyway! maybe there is something else i missed...
Given this example code, what does your actionPerformed() method look like?
It should test somewhere for the source of the ActionEvent object, like :
if (e.getActionCommand().equals("cancel")) {
...
}

Signature
Luc Van Bogaert
Marcel van Gellekom - 30 Nov 2003 13:39 GMT
> Given this example code, what does your actionPerformed() method look like?
>
[quoted text clipped - 3 lines]
> ...
> }
yes it does indeed:
public void actionPerformed(ActionEvent e) {
if ("cancel".equals(e.getActionCommand())) {
// cancel action
}
}
anything else? maybe the eclipse appletviewer cant handle this right - i
will try it out on a html page