The code taken from the book by Bashar Abdul-Javad, according to the author, should create a GUI with a text field, a button and a menu with one item.
And after entering the text and pressing the button, the text is displayed in the widget.
When I try to execute in groovyConsole.exe (Ctrl + R) - it works ...
When I run ###. Groovy, no - why?
import groovy.swing.SwingBuilder import javax.swing.JOptionPane swing = new SwingBuilder() showText = swing.action(name: 'Show Text', closure: { JOptionPane.showMessageDialog(frame, message.text)}) frame = swing.frame(title: 'Action Demo'){ menuBar{ menu('Tools'){ menuItem('Show text', action: showText) } } panel(){ message = textField(columns: 10) widget(button) } } button = swing.button(text: 'Show text', action: showText) frame.pack() frame.show()