function [pathname] = uigetdir2(start_path, dialog_title) % Pick a directory with the Java widgets instead of uigetdir import javax.swing.JFileChooser; if nargin == 0 || length(start_path) == 0 % Allow a null argument. start_path = pwd; end jchooser = javaObjectEDT('javax.swing.JFileChooser', start_path); jchooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 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