Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: necessary import

...

Example of a dialog to choose .xls files:

Code Block
import javax.swing.filechooser.FileFilter

def openExcelDialog  = fileChooser(dialogTitle:"Choose an excel file", 
                                   id:"openExcelDialog", fileSelectionMode : JFileChooser.FILES_ONLY, 
                                   //the file filter must show also directories, in order to be able to look into them
                                   fileFilter: [getDescription: {-> "*.xls"}, accept:{file-> file ==~ /.*?\.xls/ || file.isDirectory() }] as FileFilter) {
}
//later, in the controller
def fc = openExcelDialog
if(fc.showOpenDialog() != JFileChooser.APPROVE_OPTION) return //user cancelled
model.configFile = fc.selectedFile

...