@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()); } } }
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()); } }
private void jMenuItem_OpenActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jMenuItem_OpenActionPerformed // Allow user to choose a different voice (prompt set) without exiting the tool // Create a file chooser final JFileChooser openDialog = new JFileChooser(); // Set the current directory to the voice currently in use openDialog.setCurrentDirectory(getVoiceFolderPath()); openDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int result = openDialog.showDialog(AdminWindow.this, "Open Voice"); if (result == JFileChooser.APPROVE_OPTION) { File voice = openDialog.getSelectedFile(); setVoiceFolderPath(voice); // Set to the selected the voice folder path Test.output("Open voice: " + voice); setupVoice(); } else { Test.output("Open command cancelled."); } }// GEN-LAST:event_jMenuItem_OpenActionPerformed
private void saveAll(boolean export) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setToolTipText(NLS.str("file.save_all_msg")); String currentDirectory = settings.getLastSaveFilePath(); if (!currentDirectory.isEmpty()) { fileChooser.setCurrentDirectory(new File(currentDirectory)); } int ret = fileChooser.showDialog(mainPanel, NLS.str("file.select")); if (ret == JFileChooser.APPROVE_OPTION) { JadxArgs decompilerArgs = wrapper.getArgs(); decompilerArgs.setExportAsGradleProject(export); if (export) { decompilerArgs.setSkipSources(false); decompilerArgs.setSkipResources(false); } else { decompilerArgs.setSkipSources(settings.isSkipSources()); decompilerArgs.setSkipResources(settings.isSkipResources()); } settings.setLastSaveFilePath(fileChooser.getCurrentDirectory().getPath()); ProgressMonitor progressMonitor = new ProgressMonitor(mainPanel, NLS.str("msg.saving_sources"), "", 0, 100); progressMonitor.setMillisToPopup(0); wrapper.saveAll(fileChooser.getSelectedFile(), progressMonitor); } }
JFileChooser jfc = new JFileChooser(Utils.getWorkingDirectory()); jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = jfc.showDialog(null, "select directory"); if (returnVal != JFileChooser.APPROVE_OPTION) { return; JFileChooser jfc = new JFileChooser(Utils.getWorkingDirectory()); jfc.setFileSelectionMode(JFileChooser.FILES_ONLY); int returnVal = jfc.showDialog(null, "Open"); if (returnVal != JFileChooser.APPROVE_OPTION) { return;
protected void playerLoadDeck() { String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", ""); if (!lastFolder.isEmpty()) { fcSelectDeck.setCurrentDirectory(new File(lastFolder)); } int ret = fcSelectDeck.showDialog(this, "Select Deck"); if (ret == JFileChooser.APPROVE_OPTION) { File file = fcSelectDeck.getSelectedFile(); this.txtPlayerDeck.setText(file.getPath()); try { MageFrame.getPreferences().put("lastDeckFolder", file.getCanonicalPath()); } catch (IOException ex) { } } fcSelectDeck.setSelectedFile(null); }
protected String playerLoadDeck() { if (fcSelectDeck == null) { fcSelectDeck = new JFileChooser(); fcSelectDeck.setAcceptAllFileFilterUsed(false); fcSelectDeck.addChoosableFileFilter(new DeckFilter()); } String lastFolder = MageFrame.getPreferences().get("lastDeckFolder", ""); if (!lastFolder.isEmpty()) { fcSelectDeck.setCurrentDirectory(new File(lastFolder)); } int ret = fcSelectDeck.showDialog(this, "Select Deck"); if (ret == JFileChooser.APPROVE_OPTION) { File file = fcSelectDeck.getSelectedFile(); return (file.getPath()); } return ""; }
if (fchooser.showDialog(parent, btnApprove) != JFileChooser.APPROVE_OPTION) { return null;
b.setLayoutY(50); b.setOnMouseClicked(new EventHandler<MouseEvent>() { public void handle(MouseEvent event) { JFileChooser fileChooser = new JFileChooser(); fileChooser.showDialog(javafxPanel, null); } });
private String filePath; // ... public void actionPerformed(ActionEvent e) { JFileChooser chooser=new JFileChooser(); int ret = chooser.showDialog(null, "Open file"); if(ret == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); filePath = file.getPath(); } }
final JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // final File dir = new File("/ProjectName/mp3Directory"); File dir = null; int selection = fc.showDialog(null, "Open"); if(selection == JFileChooser.APPROVE_OPTION) { dir = fc.getSelectedFile(); } else { System.out.print("Please select a directory to continue"); System.exit(0); }
JFileChooser jfc = new JFileChooser(); jfc.showDialog(null,"Please Select the File"); jfc.setVisible(true); File filename = jfc.getSelectedFile(); System.out.println("File name "+filename.getName());
private String browseInstallLocation(){ String insLocation = null; JFileChooser chooser = getJFileChooser(); int returnValue = chooser.showDialog(SwingUtilities.getWindowAncestor(this), NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooseButton")); //NOI18N if(returnValue == JFileChooser.APPROVE_OPTION){ insLocation = chooser.getSelectedFile().getAbsolutePath(); } return insLocation; }
@Override public void runOnConfirmation (final JFileChooser fileChooser, final Component component, final Notifier notifier) { if (fileChooser.showDialog(component, "Ok") == JFileChooser.APPROVE_OPTION) { notifier.notify(fileChooser.getSelectedFile()); } } }
@Override public int showDialog(Component parent, String approveButtonText) throws HeadlessException { if (!JAVAFX_AVAILABLE) { return super.showDialog(parent, approveButtonText); } return showOpenDialog(parent); }
import javax.imageio.*; ... JFileChooser fileOpen = new JFileChooser(); // Get array of available formats String[] suffices = ImageIO.getReaderFileSuffixes(); // Add a file filter for each one for (int i = 0; i < suffices.length; i++) { FileFilter filter = new FileNameExtensionFilter(suffices[i] + " files", suffices[i]); fileOpen.addChoosableFileFilter(filter); } // Show dialog int ret = fileOpen.showDialog(null, "Open file");
@Override public void actionPerformed(ActionEvent e) { fc.setDialogType(JFileChooserDialogType); int result = fc.showDialog(null, null); if (result == JFileChooser.CANCEL_OPTION || result == JFileChooser.ERROR_OPTION) { return; } setPath(fc.getSelectedFile().getAbsolutePath()); } });
private void iconButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_iconButtonActionPerformed JFileChooser chooser = WizardUtils.getIconFileChooser(iconField.getText()); int ret = chooser.showDialog(this, getMessage("LBL_Select")); // NOI18N if (ret == JFileChooser.APPROVE_OPTION) { iconField.setText(chooser.getSelectedFile().getAbsolutePath()); updateData(); } }//GEN-LAST:event_iconButtonActionPerformed
/** * Open a JFileChooser to select a directory to use. */ private void chooseDirectory() { JFileChooser chooser = new JFileChooser(getCurrentPath().toFile()); chooser.setAcceptAllFileFilterUsed(false); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (chooser.showDialog(parentComponent, Language.getString("settings.chooseFolder")) == JFileChooser.APPROVE_OPTION) { setSettingValue(chooser.getSelectedFile().getPath()); } }
/** * Load settings from file. * Asks the user for a file name. */ protected void loadSettings() { if(getFileChooser().showDialog(this, "Load Settings")==JFileChooser.APPROVE_OPTION) { File file = getFileChooser().getSelectedFile(); controlcenter.loadSettings(file); } }