private void browseFiles() { jfc.setDialogTitle("Open file"); int status = jfc.showOpenDialog(this); if (status == JFileChooser.APPROVE_OPTION) { urlTextField.setText(jfc.getSelectedFile().getPath()); openButton.setEnabled(true); } }
public void actionPerformed(ActionEvent ae) { final JFileChooser jfc = new JFileChooser(); final int response = jfc.showOpenDialog(LexerFrame.this); if (response != JFileChooser.APPROVE_OPTION) { return; } safeScanScript(jfc.getSelectedFile()); } };
private void browseSoxActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseSoxActionPerformed JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // System.out.println("Opening: " + file.getAbsolutePath()); tfSoxPath.setText(file.getAbsolutePath()); } }// GEN-LAST:event_browseSoxActionPerformed
/** * Do the stuff for this class (create the file) * * @throws Exception */ public static void main(String args[]) throws Exception { System.out.println("Starting..."); String wd = "./test"; // choose the directory to open JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(wd)); chooser.setMultiSelectionEnabled(true); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int result = chooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION) { File[] dirs = chooser.getSelectedFiles(); for (File directory : dirs) { System.out.println("Doing migration on directory: " + directory.getAbsolutePath()); doMigration(directory); } } }
/** * Prompts the user for a file to load events from. * @param aIgnore an <code>ActionEvent</code> value */ public void actionPerformed(ActionEvent aIgnore) { LOG.info("load file called"); if (mChooser.showOpenDialog(mParent) == JFileChooser.APPROVE_OPTION) { LOG.info("Need to load a file"); final File chosen = mChooser.getSelectedFile(); LOG.info("loading the contents of " + chosen.getAbsolutePath()); try { final int num = loadFile(chosen.getAbsolutePath()); JOptionPane.showMessageDialog( mParent, "Loaded " + num + " events.", "CHAINSAW", JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { LOG.warn("caught an exception loading the file", e); JOptionPane.showMessageDialog( mParent, "Error parsing file - " + e.getMessage(), "CHAINSAW", JOptionPane.ERROR_MESSAGE); } } }
private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed String lastFolder = MageFrame.getPreferences().get("lastImportFolder", ""); if (!lastFolder.isEmpty()) { fcImportDeck.setCurrentDirectory(new File(lastFolder)); int ret = fcImportDeck.showOpenDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { File file = fcImportDeck.getSelectedFile(); MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR)); try {
JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(true); chooser.showOpenDialog(frame); File[] files = chooser.getSelectedFiles(); if(files.length >= 2) { compare(readFileAsList(files[0]), readFileAsList(files[1])); }
JFileChooser saveFile = new JFileChooser(); saveFile.showSaveDialog(null); JFileChooser openFile = new JFileChooser(); openFile.showOpenDialog(null);
import java.io.File; import javax.swing.JFileChooser; public class ShowDirectoriesOnly { public static void main(String[] args) { JFileChooser fileChooser = new JFileChooser( "." ); fileChooser.setControlButtonsAreShown( false ); fileChooser.setFileFilter( new FolderFilter() ); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.showOpenDialog(null); } private static class FolderFilter extends javax.swing.filechooser.FileFilter { @Override public boolean accept( File file ) { return file.isDirectory(); } @Override public String getDescription() { return "We only take directories"; } } }
private void browseSoxActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseSoxActionPerformed JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // System.out.println("Opening: " + file.getAbsolutePath()); tfSoxPath.setText(file.getAbsolutePath()); } }// GEN-LAST:event_browseSoxActionPerformed
static public void getFilename(String title, int type) { int returnVal; fileChooser.setDialogTitle(title); fileChooser.setCurrentDirectory(file); fileChooser.setDialogType(type); if (type == JFileChooser.OPEN_DIALOG) { returnVal = fileChooser.showOpenDialog(jframe); } else { returnVal = fileChooser.showSaveDialog(jframe); } if (returnVal == JFileChooser.APPROVE_OPTION) { file = fileChooser.getSelectedFile(); filename = file.getAbsolutePath(); prefs.put(FILENAME_PREFERENCE, filename); } }
fcSelectDeck.setCurrentDirectory(new File(lastFolder)); int ret = fcSelectDeck.showOpenDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { File file = fcSelectDeck.getSelectedFile(); file = new File(lastFolder);
public static File showOpenDialog(String[] exts) { JFileChooser dialog = new JFileChooser(); if (exts != null) { dialog.setFileFilter(new ExtensionFilter(exts)); } int returnVal = dialog.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { return dialog.getSelectedFile(); } return null; }
public File getFile(boolean open) { File file = null; int returnVal; if (open) { returnVal = fileChooser.showOpenDialog(frame); } else { returnVal = fileChooser.showSaveDialog(frame); } if(returnVal == JFileChooser.APPROVE_OPTION) { file = fileChooser.getSelectedFile(); if (open && !checkFile(file)) { file = null; } } return file; }
JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(true); chooser.showOpenDialog(frame); File[] files = chooser.getSelectedFiles();
private void browseInputDirActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseInputDirActionPerformed JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // System.out.println("Opening: " + file.getAbsolutePath()); tfInputDir.setText(file.getAbsolutePath()); } }// GEN-LAST:event_browseInputDirActionPerformed
private void btnBrowseImageLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrowseImageLocationActionPerformed int returnVal = fc.showOpenDialog(PreferencesDialog.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); txtImageFolderPath.setText(file.getAbsolutePath()); } }//GEN-LAST:event_btnBrowseImageLocationActionPerformed
@Override public void actionPerformed(ActionEvent event) { final JFileChooser fileChooser = new JFileChooser(model.getLastDirectory()); final FileFilter filter = new JavaFileFilter(); fileChooser.setFileFilter(filter); final int returnCode = fileChooser.showOpenDialog(MainFrame.this); if (returnCode == JFileChooser.APPROVE_OPTION) { final File file = fileChooser.getSelectedFile(); openFile(file); } }
public File getFile(boolean open) { File file = null; int returnVal; if (open) { returnVal = fileChooser.showOpenDialog(frame); } else { returnVal = fileChooser.showSaveDialog(frame); } if(returnVal == JFileChooser.APPROVE_OPTION) { file = fileChooser.getSelectedFile(); if (open && !checkFile(file)) { file = null; } } return file; }
private void browseOutputDirActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_browseOutputDirActionPerformed JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // System.out.println("Opening: " + file.getAbsolutePath()); tfOutputDir.setText(file.getAbsolutePath()); } }// GEN-LAST:event_browseOutputDirActionPerformed