From e3f67261509093c7a604df85dc73fbf03fe22b5c Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Wed, 29 Jul 2009 15:44:51 +0000 Subject: [PATCH] Bugfix: Solves HEADLESS crash on Macs. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@1349 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/settings/FileSetting.java | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/prism/src/settings/FileSetting.java b/prism/src/settings/FileSetting.java index 7dd1ccd8..243ebf5d 100644 --- a/prism/src/settings/FileSetting.java +++ b/prism/src/settings/FileSetting.java @@ -46,19 +46,27 @@ public class FileSetting extends Setting private static FileSelector defaultSelector() { - return new FileSelector() - { - JFileChooser choose = new JFileChooser(); - - public File getFile(Frame parent, File defaultFile) + try { + return new FileSelector() { - choose.setSelectedFile(defaultFile); - int choice = choose.showOpenDialog(parent); - if(choice == JFileChooser.CANCEL_OPTION) return null; - else return choose.getSelectedFile(); + JFileChooser choose = new JFileChooser(); - } - }; + public File getFile(Frame parent, File defaultFile) + { + choose.setSelectedFile(defaultFile); + int choice = choose.showOpenDialog(parent); + if(choice == JFileChooser.CANCEL_OPTION) return null; + else return choose.getSelectedFile(); + + } + }; + } + // Catch any problems that occur when running in headless mode + // (e.g. the command-line version of PRISM) + // (in this case, you don't need this object anyway) + catch (HeadlessException e) { + return null; + } } private boolean validFile;