File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ function [pathname ] = uigetfiles(FilterSpec ,DialogTitle ,varargin )
2+ % Pick multiple directories and/or files
3+
4+ import javax .swing .JFileChooser ;
5+ % First check inputs
6+ start_path = ' ' ;
7+ multi = 1 ;
8+ dialog_title = [];
9+
10+ if isempty(start_path ) % Allow a null argument.
11+ start_path = pwd ;
12+ end
13+
14+ jchooser = javaObjectEDT(' javax.swing.JFileChooser' , start_path );
15+
16+ jchooser .setFileSelectionMode(JFileChooser .FILES_AND_DIRECTORIES );
17+ if ~isempty(dialog_title )
18+ jchooser .setDialogTitle(dialog_title );
19+ end
20+
21+ if multi == 0
22+ jchooser .setMultiSelectionEnabled(false );
23+ elseif multi == 1
24+ jchooser .setMultiSelectionEnabled(true );
25+ end
26+
27+ status = jchooser .showOpenDialog([]);
28+
29+ if status == JFileChooser .APPROVE_OPTION
30+ jFile = jchooser .getSelectedFiles();
31+ pathname{size(jFile , 1 )}=[];
32+ for i= 1 : size(jFile , 1 )
33+ pathname{i } = char(jFile(i ).getAbsolutePath);
34+ end
35+
36+ elseif status == JFileChooser .CANCEL_OPTION
37+ pathname = [];
38+ else
39+ error(' Error occured while picking file.' );
40+ end
You can’t perform that action at this time.
0 commit comments