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
public File doSaveDialog(String recommendedFileName) { File selectedFile = null; initSaveDialog(); retrieveSaveDialogDir(fcSave); fcSave.setSelectedFile(new File(recommendedFileName)); int returnVal = fcSave.showSaveDialog(parent); saveSaveDialogDir(fcSave); if (returnVal == JFileChooser.APPROVE_OPTION) { selectedFile = fcSave.getSelectedFile(); } return selectedFile; }
private static JFileChooser createFileChooser() { final JFileChooser chooser = new JFileChooser(); // sets up default file view try { chooserFile = new File((new File(".").getCanonicalPath())); } catch (Exception e) { // go with current directory. } chooser.setCurrentDirectory(chooserFile); chooser.addActionListener(e -> { if(e.getActionCommand().equals("ApproveSelection")) { chooserFile = chooser.getSelectedFile(); } }); chooser.setMultiSelectionEnabled(true); chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); return chooser; }
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 {
/** * 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); } } }
@Override public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(rootDirectoryField.getText()); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fc.showDialog(frame, "Select"); if (fc.getSelectedFile() != null) { rootDirectoryField.setText(fc.getSelectedFile().getAbsolutePath()); } } }
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); } }
public static File showSaveDialog(String[] exts) { JFileChooser dialog = new JFileChooser(); if (exts != null) { dialog.setFileFilter(new ExtensionFilter(exts)); } int returnVal = dialog.showSaveDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { return dialog.getSelectedFile(); } return null; }
/** * Opens a dialog and saves the output of the parser on the current * text. If there is no current text, yell at the user and make * them feel bad instead. */ public void saveOutput() { if (textPane.getText().trim().length() == 0) { JOptionPane.showMessageDialog(this, "No text to parse ", null, JOptionPane.ERROR_MESSAGE); return; } jfc.setDialogTitle("Save file"); int status = jfc.showSaveDialog(this); if (status == JFileChooser.APPROVE_OPTION) { saveOutput(jfc.getSelectedFile().getPath()); } }
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 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
public File doSaveAllDialog(String recommendedFileName) { File selectedFile = null; initSaveAllDialog(); retrieveSaveDialogDir(fcSaveAll); fcSaveAll.setSelectedFile(new File(recommendedFileName)); int returnVal = fcSaveAll.showSaveDialog(parent); saveSaveDialogDir(fcSaveAll); if (returnVal == JFileChooser.APPROVE_OPTION) { selectedFile = fcSaveAll.getSelectedFile(); } return selectedFile; }
public void openFile() { JFileChooser fileChooser = new JFileChooser(); fileChooser.setAcceptAllFileFilterUsed(true); String[] exts = {"apk", "dex", "jar", "class", "zip", "aar", "arsc"}; String description = "supported files: " + Arrays.toString(exts).replace('[', '(').replace(']', ')'); fileChooser.setFileFilter(new FileNameExtensionFilter(description, exts)); fileChooser.setToolTipText(NLS.str("file.open_action")); String currentDirectory = settings.getLastOpenFilePath(); if (!currentDirectory.isEmpty()) { fileChooser.setCurrentDirectory(new File(currentDirectory)); } int ret = fileChooser.showDialog(mainPanel, NLS.str("file.open_title")); if (ret == JFileChooser.APPROVE_OPTION) { settings.setLastOpenFilePath(fileChooser.getCurrentDirectory().getPath()); openFile(fileChooser.getSelectedFile()); } }
fcSelectDeck.setCurrentDirectory(new File(lastFolder)); int ret = fcSelectDeck.showOpenDialog(this); if (ret == JFileChooser.APPROVE_OPTION) { File file = fcSelectDeck.getSelectedFile(); file = new File(lastFolder);
private void btnBrowseBackgroundImageActionPerformed(java.awt.event.ActionEvent evt) { int returnVal = fc_i.showOpenDialog(PreferencesDialog.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc_i.getSelectedFile(); txtBackgroundImagePath.setText(file.getAbsolutePath()); } }
/** * Uses a JFileChooser to select a file to opened with the * LF5 GUI. */ protected void requestOpen() { JFileChooser chooser; if (_fileLocation == null) { chooser = new JFileChooser(); } else { chooser = new JFileChooser(_fileLocation); } int returnVal = chooser.showOpenDialog(_logMonitorFrame); if (returnVal == JFileChooser.APPROVE_OPTION) { File f = chooser.getSelectedFile(); if (loadLogFile(f)) { _fileLocation = chooser.getSelectedFile(); _mruFileManager.set(f); updateMRUList(); } } }
@Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); boolean cont = chooser.showSaveDialog(SpoonModelTree.this) == JFileChooser.APPROVE_OPTION; if (cont) { SerializationModelStreamer ser = new SerializationModelStreamer(); try { ser.save(factory, new FileOutputStream(chooser .getSelectedFile())); } catch (IOException e1) { Launcher.LOGGER.error(e1.getMessage(), e1); } } } });
/** * Show a save dialog with the file chooser set up according to the * parameters of this builder. * @return A file if the user clicks the accept button and a file or * folder was selected at the time the user clicked cancel. */ public File showSaveDialog() { JFileChooser chooser = createFileChooser(); if( Boolean.getBoolean("nb.native.filechooser") ) { //NOI18N FileDialog fileDialog = createFileDialog( chooser.getCurrentDirectory() ); if( null != fileDialog ) { return showFileDialog( fileDialog, FileDialog.SAVE ); } } int result = chooser.showSaveDialog(findDialogParent()); if (JFileChooser.APPROVE_OPTION == result) { return chooser.getSelectedFile(); } else { return null; } }