john renfrew Posted June 6, 2011 Posted June 6, 2011 Some while ago I reported intermittent problems when using an adaption of the jFileChooser method on Mac platform. As soon as the file choice dialog box appears on screen clicking anwhere on it causes a spinning beachball of death and Filemaker has to be crashed, which as we all know is one sure fire way to damage a file. I wonder if you have made any progress on finding why? FM 11.0.3 and the latest SM plugin OSX 10.6.7 // ChooseFiltered(fm_Path, fm_Message, fm_FileType, fm_Button, fm_Select) // 11_06_02_JR WORKING // v1.2 // fm_Path startpath for dialog // fm_Message for dialog title // fm_Button sets text for default 'accept' button // fm_FileType selects file filter - p > pdf, i > images, f > fonts // ... d > documents, x > data files, z > archives, a > all filters, null > no filters // fm_Select is flag to set what is selected - f > files, d > dirs, null > both if (System.getProperty("java.version").substring(0, 2) == "1." && System.getProperty("java.version").substring(2, 3).toInteger() < 6 ){ return 'ERROR' } import javax.swing.JFileChooser import javax.swing.filechooser.FileNameExtensionFilter chooser = new JFileChooser() if (fm_Select == "d"){ chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY ) } if (fm_Select == "f"){ chooser.setFileSelectionMode( JFileChooser.FILES_ONLY ) } else chooser.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES ) if( fm_Path != null ) chooser.setCurrentDirectory( new File(fm_Path) ) if( fm_Message != null ) chooser.setDialogTitle( fm_Message ) //chooser.setFileHidingEnabled(false) // sets whether or not hidden files are shown pdf = new FileNameExtensionFilter( "PDF files", "pdf" ) img = new FileNameExtensionFilter( "Image files", "jpg", "gif", "jpeg", "png", "tif", "bmp" ) doc = new FileNameExtensionFilter( "Documents", "doc", "docx", "txt", "wri", "htm", "html", "css", "log" ) xml = new FileNameExtensionFilter( "Data files", "csv", "xls", "xlsx", "xml", "tab", "xsl" ) zip = new FileNameExtensionFilter( "Archives", "zip", "dmg", "jar", "rar" ) fnt = new FileNameExtensionFilter( "Fonts", "ttf", "otf" ) if ( fm_FileType == "i"){ chooser.setFileFilter(img) } else if ( fm_FileType == "d"){ chooser.setFileFilter(doc) } else if ( fm_FileType == "p"){ chooser.setFileFilter(pdf) } else if ( fm_FileType == "x"){ chooser.setFileFilter(xml) } else if ( fm_FileType == "z"){ chooser.setFileFilter(zip) } else if ( fm_FileType == "f"){ chooser.setFileFilter(fnt) } else if ( fm_FileType == "a"){ chooser.addChoosableFileFilter(img) chooser.addChoosableFileFilter(doc) chooser.addChoosableFileFilter(pdf) chooser.addChoosableFileFilter(xml) chooser.addChoosableFileFilter(zip) chooser.addChoosableFileFilter(fnt) chooser.setAcceptAllFileFilterUsed(true) } else if ( fm_FileType == null){ chooser.setAcceptAllFileFilterUsed(true) } chooser.setApproveButtonText(fm_Button) chooser.setApproveButtonToolTipText("Import this file") //chooser.setAcceptAllFileFilterUsed(false) if( chooser.showOpenDialog( null ) == JFileChooser.APPROVE_OPTION ) { // select depending on format you require to be returned //return chooser.getSelectedFile().getCanonicalPath() return chooser.getSelectedFile().getAbsolutePath() } else return false
ron G Posted February 27, 2012 Posted February 27, 2012 I too get the 'beach ball of death' but (and this is the good news) I can select a file or click 'cancel' as if I had a regular mouse pointer. It is just 'weird'.... Ron Feb 2012
Jesse Barnum Posted February 27, 2012 Posted February 27, 2012 Make sure that you have the function in question checked as a GUI function.
ron G Posted March 3, 2012 Posted March 3, 2012 I think I 'got it'. If I set Allow User Abort [On] everything works as expected. If I set Allow User Abort [Off] I get the spinning ball. (Unless I answer the preceeding dialog with an OK within 2 seconds)
Recommended Posts
This topic is 4717 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now