I'm creating a menu by reading a directory off the disk and creating a menuItem for each file in that directory.
I'd like to have it re-read the disk every time that menu is clicked.
SwingBuilder doesn't seem to want to do this-- at least not easily.
Do I have to add a closure to the "Menu" that creates the MenuItems using old-school swing (I don't even know if this would work since you've already clicked the menu), or is there some trick to get SwingBuilder to re-evaluate a section whenever it is entered?
Here's what I have now:
File scriptDir = new File("C:/myBatchFiles")
menu(text:"External tools", visible:scriptDir.isDirectory()) {
scriptDirlistFiles().each{
File oneItem ->
String name = oneItem.name
String command = '"' + scriptDir.path + '/' + name + '"'
menuItem(action(name:name){MyUtils.cmd(command)}
}
}