Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#279 Problem defining anonymous Action object

open
nobody
General (151)
5
2007-01-04
2007-01-04
Gary Nunes
No

I tried defining the following:

JMenuItem mi = new JMenuItem(new AbstractAction("Item") {
public void actionPerformed(ActionEvent e) {
// your code here
}
});

which failed though it's valid Java code.

However, this works:

JMenuItem mm = new JMenuItem(new AbstractAction() {
public void actionPerformed(ActionEvent e) {
// your code here
}
});

Seems like not all the AbstractAction constructors are supported (or perhaps not all anonymous declaration syntax).

Discussion