(final String prompt,
final String callbackMethod,
final File defaultSelection,
final Object callbackObject,
final Frame parentFrame)
| 872 | |
| 873 | |
| 874 | static public void selectFolderImpl(final String prompt, |
| 875 | final String callbackMethod, |
| 876 | final File defaultSelection, |
| 877 | final Object callbackObject, |
| 878 | final Frame parentFrame) { |
| 879 | File selectedFile = null; |
| 880 | if (PApplet.platform == PConstants.MACOS && PApplet.useNativeSelect) { |
| 881 | FileDialog fileDialog = |
| 882 | new FileDialog(parentFrame, prompt, FileDialog.LOAD); |
| 883 | if (defaultSelection != null) { |
| 884 | fileDialog.setDirectory(defaultSelection.getAbsolutePath()); |
| 885 | } |
| 886 | System.setProperty("apple.awt.fileDialogForDirectories", "true"); |
| 887 | fileDialog.setVisible(true); |
| 888 | System.setProperty("apple.awt.fileDialogForDirectories", "false"); |
| 889 | String filename = fileDialog.getFile(); |
| 890 | if (filename != null) { |
| 891 | selectedFile = new File(fileDialog.getDirectory(), fileDialog.getFile()); |
| 892 | } |
| 893 | } else { |
| 894 | checkLookAndFeel(); |
| 895 | JFileChooser fileChooser = new JFileChooser(); |
| 896 | fileChooser.setDialogTitle(prompt); |
| 897 | fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| 898 | if (defaultSelection != null) { |
| 899 | fileChooser.setCurrentDirectory(defaultSelection); |
| 900 | } |
| 901 | |
| 902 | int result = fileChooser.showOpenDialog(parentFrame); |
| 903 | if (result == JFileChooser.APPROVE_OPTION) { |
| 904 | selectedFile = fileChooser.getSelectedFile(); |
| 905 | } |
| 906 | } |
| 907 | PApplet.selectCallback(selectedFile, callbackMethod, callbackObject); |
| 908 | } |
| 909 | |
| 910 | |
| 911 | static private boolean lookAndFeelCheck; |
no test coverage detected