I ran this past a Groovy-oriented co-worker, and we found that (a) earlier versions of Groovy didn't really support nested/inner classes at all, (b) the current Groovy versions mostly support them now, but (c) the OuterClass.this syntax is still not supported by Groovy. Maybe it will be in the future, but so far, no.
Looking further at your code, it's not clear why you might need this anyway. You basically are doing three things with the button:
1. Create a button.
2. Add it to the JPanel
3. Add an action listener.
There's no reason this all has to be done inside an instance initializer of an anonymous class, though. That's just needlessly confusing to me. (And to Groovy, apparently.) How about:
I also removed the stuff about doing everything in the event dispatch
thread. That seems unnecessary given that the button hasn't been displayed yet - that's the last thing that happens in this code. It makes little difference in this app, but in general I would avoid putting too much in the event dispatch thread - at least,
unnecessary stuff - because that's what slows down your app's reaction to everything else that might happen.
My co-worker also offered this more Groovy version of the code (does not work as Java):
But really, if you're using Groovy, you probably want SwingBuilder - you code will be much nicer.