forked from jamesvenning/matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuigetdir2.m
32 lines (24 loc) · 812 Bytes
/
uigetdir2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function [pathname] = uigetdir2(start_path, dialog_title)
% Pick multiple directories and/or files
import javax.swing.JFileChooser;
if nargin == 0 || start_path == '' || start_path == 0 % Allow a null argument.
start_path = pwd;
end
jchooser = javaObjectEDT('javax.swing.JFileChooser', start_path);
jchooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
if nargin > 1
jchooser.setDialogTitle(dialog_title);
end
jchooser.setMultiSelectionEnabled(true);
status = jchooser.showOpenDialog([]);
if status == JFileChooser.APPROVE_OPTION
jFile = jchooser.getSelectedFiles();
pathname{size(jFile, 1)}=[];
for i=1:size(jFile, 1)
pathname{i} = char(jFile(i).getAbsolutePath);
end
elseif status == JFileChooser.CANCEL_OPTION
pathname = [];
else
error('Error occured while picking file.');
end