/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile() { return promptToOpenFile((String)null); }
/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * @param existingFileName The name of a file with path. If the filename points * to an existing file, the directory in which it lies, will be used * as the starting point for the returned JFileChooser. * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile(String existingFileName) { return promptToOpenFile(new String[0], existingFileName); }
/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * @param exts The list of allowed file extensions. If empty, any * file extension is allowed * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile(String[] exts) { return promptToOpenFile(exts, null); }
/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * @param exts The list of allowed file extensions. If empty, any * file extension is allowed * @param existingFileName The name of a file with path. If the filename points * to an existing file, the directory in which it lies, will be used * as the starting point for the returned JFileChooser. * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile(String[] exts, String existingFileName) { return promptToOpenFile(exts, null, false); }
/** * Prompts the user to choose a file or a directory from their filesystems for our own * devious uses. This method maintains the last directory the user visited * before dismissing the dialog. This does NOT imply they actually chose a * file from that directory, only that they closed the dialog there. It is * the caller's responsibility to check to see if the selected file is * non-null. * @param existingFileName The name of a file with path. If the filename points * to an existing file, the directory in which it lies, will be used * as the starting point for the returned JFileChooser. * @param onlyDirectories If true, only directories are displayed in the FileChooser * * @return the JFileChooser that interacted with the user, after they are * finished using it - null if no file was chosen */ public static JFileChooser promptToOpenFile(String existingFileName, boolean onlyDirectories) { return promptToOpenFile(new String[0], existingFileName, onlyDirectories); }
/** * opens a dialog box to choose a file and returns selected file's * path. * * @return a new File object */ private String browseAndGetFilePath() { String path = ""; //$NON-NLS-1$ JFileChooser chooser = FileDialoger.promptToOpenFile(); if (chooser != null) { File file = chooser.getSelectedFile(); if (file != null) { path = file.getPath(); } } return path; }
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(ACTION_BROWSE)) { JFileChooser chooser; if(filetypes == null || filetypes.length == 0){ chooser = FileDialoger.promptToOpenFile(filename.getText(),onlyDirectories); } else { chooser = FileDialoger.promptToOpenFile(filetypes, filename.getText(),onlyDirectories); } if (chooser != null && chooser.getSelectedFile() != null) { filename.setText(chooser.getSelectedFile().getPath()); fireFileChanged(); } } else { fireFileChanged(); } } }
/** * {@inheritDoc} */ @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = FileDialoger.promptToOpenFile(); if (chooser == null){ return; } setValue(toUnix(chooser.getSelectedFile())); }
@Override public void doActionAfterCheck(final ActionEvent e) { final JFileChooser chooser = FileDialoger.promptToOpenFile(new String[] { ".jmx" }); //$NON-NLS-1$ if (chooser == null) { return; } final File selectedFile = chooser.getSelectedFile(); if (selectedFile != null) { final boolean merging = e.getActionCommand().equals(ActionNames.MERGE); // We must ask the user if it is ok to close current project if (!merging) { // i.e. it is OPEN if (!Close.performAction(e)) { return; } } loadProjectFile(e, selectedFile, merging); } }
try { final String [] _txt={".txt"}; //$NON-NLS-1$ final JFileChooser dialog = FileDialoger.promptToOpenFile(_txt); if (dialog != null) { tableModel.manager.addFile(dialog.getSelectedFile().getAbsolutePath());
} else if (action.equals(LOAD_COMMAND)) { try { final JFileChooser chooser = FileDialoger.promptToOpenFile(); if (chooser != null) { headerManager.addFile(chooser.getSelectedFile().getAbsolutePath());
try { final String [] _txt={".txt"}; //$NON-NLS-1$ final JFileChooser chooser = FileDialoger.promptToOpenFile(_txt); if (chooser != null) { CookieManager manager = new CookieManager();