List of usage examples for javafx.stage FileChooser setInitialDirectory
public final void setInitialDirectory(final File value)
From source file:ninja.javafx.smartcsv.fx.SmartCSVController.java
private void loadFile(String filterText, String filter, String title, FileStorage storageFile) { final FileChooser fileChooser = new FileChooser(); //Set extension filter final FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter(filterText, filter); fileChooser.getExtensionFilters().add(extFilter); fileChooser.setTitle(title);/*from w w w. j a va 2 s. co m*/ if (storageFile.getFile() != null) { fileChooser.setInitialDirectory(storageFile.getFile().getParentFile()); } //Show open file dialog File file = fileChooser.showOpenDialog(applicationPane.getScene().getWindow()); if (file != null) { storageFile.setFile(file); useLoadFileService(storageFile, t -> resetContent()); } }
From source file:dsfixgui.view.DSPWPane.java
private void initializeEventHandlers() { applySettingsButton.setOnAction(e -> { ui.applyDSPWConfig();// w w w .j a va2 s . c om }); restoreDefaultsButton.setOnAction(e -> { ContinueDialog cD = new ContinueDialog(300.0, 80.0, DIALOG_TITLE_RESET, DIALOG_MSG_RESTORE_SETTINGS, DIALOG_BUTTON_TEXTS[2], DIALOG_BUTTON_TEXTS[1]); if (cD.show()) { config.restoreDefaults(); ui.refreshUI(); } }); versionBannerOn.setOnAction(e -> { config.ShowVersionBanner.replace(0, config.ShowVersionBanner.length(), TRUE_FALSE[0]); }); versionBannerOff.setOnAction(e -> { config.ShowVersionBanner.replace(0, config.ShowVersionBanner.length(), TRUE_FALSE[1]); }); overlayOn.setOnAction(e -> { config.ShowOverlay.replace(0, config.ShowOverlay.length(), TRUE_FALSE[0]); }); overlayOff.setOnAction(e -> { config.ShowOverlay.replace(0, config.ShowOverlay.length(), TRUE_FALSE[1]); }); invasionNotifOn.setOnAction(e -> { config.InvasionSoundNotification.replace(0, config.InvasionSoundNotification.length(), TRUE_FALSE[0]); }); invasionNotifOff.setOnAction(e -> { config.InvasionSoundNotification.replace(0, config.InvasionSoundNotification.length(), TRUE_FALSE[1]); }); cheaterNotifOn.setOnAction(e -> { config.CheaterSoundNotification.replace(0, config.CheaterSoundNotification.length(), TRUE_FALSE[0]); }); cheaterNotifOff.setOnAction(e -> { config.CheaterSoundNotification.replace(0, config.CheaterSoundNotification.length(), TRUE_FALSE[1]); }); blockArenaFreezeOn.setOnAction(e -> { config.BlockArenaFreeze.replace(0, config.BlockArenaFreeze.length(), TRUE_FALSE[0]); }); blockArenaFreezeOff.setOnAction(e -> { config.BlockArenaFreeze.replace(0, config.BlockArenaFreeze.length(), TRUE_FALSE[1]); }); nodeCountOn.setOnAction(e -> { config.ShowNodeDbCount.replace(0, config.ShowNodeDbCount.length(), TRUE_FALSE[0]); }); nodeCountOff.setOnAction(e -> { config.ShowNodeDbCount.replace(0, config.ShowNodeDbCount.length(), TRUE_FALSE[1]); }); increaseNodesOn.setOnAction(e -> { config.IncreaseNodeDbLimit.replace(0, config.IncreaseNodeDbLimit.length(), TRUE_FALSE[0]); }); increaseNodesOff.setOnAction(e -> { config.IncreaseNodeDbLimit.replace(0, config.IncreaseNodeDbLimit.length(), TRUE_FALSE[1]); }); dateOn.setOnAction(e -> { config.DisplayDate.replace(0, config.DisplayDate.length(), TRUE_FALSE[0]); }); dateOff.setOnAction(e -> { config.DisplayDate.replace(0, config.DisplayDate.length(), TRUE_FALSE[1]); }); timeOn.setOnAction(e -> { config.DisplayClock.replace(0, config.DisplayClock.length(), TRUE_FALSE[0]); }); timeOff.setOnAction(e -> { config.DisplayClock.replace(0, config.DisplayClock.length(), TRUE_FALSE[1]); }); updateOn.setOnAction(e -> { config.CheckForUpdates.replace(0, config.CheckForUpdates.length(), TRUE_FALSE[0]); }); updateOff.setOnAction(e -> { config.CheckForUpdates.replace(0, config.CheckForUpdates.length(), TRUE_FALSE[1]); }); textAlignmentLeft.setOnAction(e -> { config.TextAlignment.replace(0, config.TextAlignment.length(), DSPW_TEXT_ALIGNMENT_OPTIONS[0]); }); textAlignmentCenter.setOnAction(e -> { config.TextAlignment.replace(0, config.TextAlignment.length(), DSPW_TEXT_ALIGNMENT_OPTIONS[1]); }); textAlignmentRight.setOnAction(e -> { config.TextAlignment.replace(0, config.TextAlignment.length(), DSPW_TEXT_ALIGNMENT_OPTIONS[2]); }); fontSizeField.textProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldText, String newText) { try { if (!NumberUtils.isParsable(newText) || Integer.parseInt(newText) > 72 || Integer.parseInt(newText) < 15) { fontSizeField.pseudoClassStateChanged(INVALID_INPUT, true); } else { fontSizeField.pseudoClassStateChanged(INVALID_INPUT, false); config.FontSize.replace(0, config.FontSize.length(), "" + Integer.parseInt(newText)); } } catch (NumberFormatException nFE) { ui.printConsole(INPUT_TOO_LARGE); fontSizeField.setText(""); } } }); dllChainButton.setOnAction(e -> { FileChooser dllChooser = new FileChooser(); dllChooser.setTitle(DIALOG_TITLE_DLL); if (ui.getDataFolder() != null) { dllChooser.setInitialDirectory(ui.getDataFolder()); } ExtensionFilter dllFilter = new ExtensionFilter(DLL_EXT_FILTER[0], DLL_EXT_FILTER[1]); dllChooser.getExtensionFilters().add(dllFilter); File dll = dllChooser.showOpenDialog(ui.getStage()); if (dll != null && ui.getDataFolder() != null) { File checkDLL = new File(ui.getDataFolder() + "\\" + dll.getName()); if (!checkDLL.exists()) { AlertDialog aD = new AlertDialog(300.0, 80.0, DIALOG_TITLE_WRONG_FOLDER, DLL_MUST_BE_IN_DATA, DIALOG_BUTTON_TEXTS[0]); } else { if (dll.getName().equals(DSM_FILES[0])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DLL_WITH_DSM, DIALOG_BUTTON_TEXTS[0]); } else if (dll.getName().equals(DSF_FILES[0])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DLL_WITH_DSF, DIALOG_BUTTON_TEXTS[0]); } else if (dll.getName().equals(DS_DEFAULT_DLLS[0]) || dll.getName().equals(DS_DEFAULT_DLLS[1]) || dll.getName().equals(DS_DEFAULT_DLLS[2])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DLL_WITH_DEFAULT, DIALOG_BUTTON_TEXTS[0]); } else if (dll.getName().equals(DSPW_FILES[1]) || dll.getName().equals(DSPW_FILES[4]) || dll.getName().equals(DSPW_FILES[5])) { AlertDialog aD = new AlertDialog(300.0, 80.0, INVALID_DLL, CANT_CHAIN_DSPW_WITH_DSPW, DIALOG_BUTTON_TEXTS[0]); } else { config.d3d9dllWrapper.replace(0, config.d3d9dllWrapper.length(), dll.getName()); dllChainField.setText(dll.getName()); dllChainField.setStyle("-fx-text-fill: black;"); noChainButton.setDisable(false); } } } }); noChainButton.setOnAction(e -> { dllChainField.setText(NONE); noChainButton.setDisable(true); dllChainField.setStyle("-fx-text-fill: gray;"); config.d3d9dllWrapper.replace(0, config.d3d9dllWrapper.length(), NONE); }); banPicker.setOnAction(e -> { config.key_BanPhantom.replace(0, config.key_BanPhantom.length(), keybindsHex.get(keybinds.indexOf(banPicker.getValue()))); }); ignorePicker.setOnAction(e -> { config.key_IgnorePhantom.replace(0, config.key_IgnorePhantom.length(), keybindsHex.get(keybinds.indexOf(ignorePicker.getValue()))); }); toggleOverlayPicker.setOnAction(e -> { config.key_HideOverlay.replace(0, config.key_HideOverlay.length(), keybindsHex.get(keybinds.indexOf(toggleOverlayPicker.getValue()))); }); aboutPicker.setOnAction(e -> { config.key_AboutDSPW.replace(0, config.key_AboutDSPW.length(), keybindsHex.get(keybinds.indexOf(aboutPicker.getValue()))); }); }
From source file:condorclient.CreateJobDialogController.java
/** * Initializes the controller class./*from ww w. j a v a2 s. c o m*/ */ @FXML private void infoFileChooserFired(ActionEvent event) { final FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("??"); fileChooser.setInitialDirectory(new File(infoFileInitialDir)); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("IXL", "*.ixl")); File file = fileChooser.showOpenDialog(this.stage); if (file != null) { infoFileText.setText(file.getAbsolutePath()); infoFileInitialDir = file.getParent(); System.out.println("infoFileInitialDir:" + infoFileInitialDir); // System.out.println(file.getName()); // openFile(file); } infoOk = true; enableButton(); }
From source file:condorclient.CreateJobDialogController.java
@FXML private void expFileChooserFired(ActionEvent event) { final FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(""); fileChooser.setInitialDirectory(new File(expFileInitialDir)); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("EXL", "*.exl")); File file = fileChooser.showOpenDialog(this.stage); String s = ""; if (file != null) { expFileText.setText(file.getAbsolutePath()); expFileInitialDir = file.getParent(); XMLHandler handler = new XMLHandler(); s = handler.getNRun(file.getAbsolutePath()); }/* w w w . java 2 s .co m*/ sampleNumText.setText(s); sampleNumText.setDisable(true); //? expOk = true; enableButton(); }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void handleExportButtonAction(ActionEvent event) { FileChooser fileChooser = new FileChooser(); //Set extension filter FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("CSV (*.csv)", "*.csv"); fileChooser.getExtensionFilters().add(extFilter); FileChooser.ExtensionFilter allFilter = new FileChooser.ExtensionFilter("All files (*)", "*"); fileChooser.getExtensionFilters().add(allFilter); String currentDir = System.getProperty("user.dir"); fileChooser.setInitialDirectory(new File(currentDir)); //Show save file dialog File file = fileChooser.showSaveDialog(primaryStage); if (file != null) { try {//from ww w .j ava 2s .co m CSV.setAddQuotesAlways(true); CSV.setCsvSeparator(csvSeparator); Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file))); ObservableList<Term> terms = tblTerms.getItems(); writer.append(CSV.format("Term") + CSV.format("Frequency") + CSV.format("Expansions") + CSV.format("Contexts") + "\n"); for (Term term : terms) { if (term instanceof TermWrapper) { term = ((TermWrapper) term).getWrappedTerm(); } writer.append(CSV.format(term.getText())); writer.append(CSV.format(term.getFrequency())); writer.append(CSV.format(term.getExpansionCount())); StringBuilder sb = new StringBuilder(); for (Context context : terminologyBase.getContexts(term)) { sb.append(context.getTextSegment() + "|"); } writer.append(CSV.format(sb.toString())); writer.append("\n"); writer.flush(); } writer.close(); } catch (IOException ioe) { throw new RuntimeException(ioe); } } }
From source file:acmi.l2.clientmod.xdat.Controller.java
@FXML private void open() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open interface.xdat"); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("XDAT (*.xdat)", "*.xdat"), new FileChooser.ExtensionFilter("All files", "*.*")); if (initialDirectory.getValue() != null && initialDirectory.getValue().exists() && initialDirectory.getValue().isDirectory()) fileChooser.setInitialDirectory(initialDirectory.getValue()); File selected = fileChooser.showOpenDialog(editor.getStage()); if (selected == null) return;// w w w. ja v a2s . c om xdatFile.setValue(selected); initialDirectory.setValue(selected.getParentFile()); try { IOEntity xdat = editor.getXdatClass().getConstructor().newInstance(); editor.execute(() -> { CountingInputStream cis = new CountingInputStream( new BufferedInputStream(new FileInputStream(selected))); try (InputStream is = cis) { xdat.read(is); Platform.runLater(() -> editor.setXdatObject(xdat)); } catch (Exception e) { log.log(Level.WARNING, String.format("Read error before offset 0x%x", cis.getCount()), e); throw e; } return null; }, e -> Platform.runLater(() -> Dialogs.show(Alert.AlertType.ERROR, "Read error", null, "Try to choose another version"))); } catch (ReflectiveOperationException e) { log.log(Level.WARNING, "XDAT class should have empty public constructor", e); Dialogs.show(Alert.AlertType.ERROR, "ReflectiveOperationException", null, "XDAT class should have empty public constructor"); } }
From source file:editeurpanovisu.EquiCubeDialogController.java
/** * * @return liste des fichiers//w ww .ja v a2 s . c o m */ private File[] choixFichiers() { File[] fileLstFich = null; FileChooser fcRepertChoix = new FileChooser(); fcRepertChoix.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("fichier Image (*.jpg|*.bmp|*.tif)", "*.jpg", "*.bmp", "*.tif")); File fileRepert = new File(strRepertFichier + File.separator); fcRepertChoix.setInitialDirectory(fileRepert); List<File> fileListe = fcRepertChoix.showOpenMultipleDialog(stTransformations); int i = 0; boolean bAttention = false; if (fileListe != null) { File[] fileLstFich1 = new File[fileListe.size()]; for (File fileLst : fileListe) { if (i == 0) { strRepertFichier = fileLst.getParent(); } String strNomFich = fileLst.getAbsolutePath(); String strExtension; strExtension = strNomFich.substring(strNomFich.lastIndexOf(".") + 1, strNomFich.length()) .toLowerCase(); Image img = null; if (!strExtension.equals("tif")) { img = new Image("file:" + strNomFich); } else { try { img = ReadWriteImage.readTiff(strNomFich); } catch (ImageReadException | IOException ex) { Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null, ex); } } if (strTypeTransformation.equals(EquiCubeDialogController.EQUI2CUBE)) { if (img.getWidth() == 2 * img.getHeight()) { fileLstFich1[i] = fileLst; i++; } else { bAttention = true; } } else { if (img.getWidth() == img.getHeight()) { String strNom = fileLst.getAbsolutePath().substring(0, fileLst.getAbsolutePath().length() - 6); boolean bTrouve = false; for (int j = 0; j < i; j++) { String strNom1 = fileLstFich1[j].getAbsolutePath().substring(0, fileLst.getAbsolutePath().length() - 6); if (strNom.equals(strNom1)) { bTrouve = true; } } if (!bTrouve) { fileLstFich1[i] = fileLst; i++; } } else { bAttention = true; } } } if (bAttention) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle(rbLocalisation.getString("transformation.traiteImages")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("transformation.traiteImagesType")); alert.showAndWait(); } fileLstFich = new File[i]; System.arraycopy(fileLstFich1, 0, fileLstFich, 0, i); lblDragDropE2C.setVisible(false); } return fileLstFich; }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleExportTXT(Event event) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export to TXT"); fileChooser.getExtensionFilters().add(new ExtensionFilter("TXT", "*.txt")); // Remember last directory if (lastSaveDirectory != null && lastSaveDirectory.isDirectory()) fileChooser.setInitialDirectory(lastSaveDirectory); // Show the file chooser File file = fileChooser.showSaveDialog(chartNode.getScene().getWindow()); // If nothing was chosen, quit if (file == null) return;/*w w w. ja v a2 s . com*/ // Save the last open directory lastSaveDirectory = file.getParentFile(); final List<MsSpectrum> spectra = new ArrayList<>(); for (MsSpectrumDataSet dataset : datasets) { spectra.add(dataset.getSpectrum()); } // Do the export in a new thread final File finalFile = file; new Thread(() -> { try { TxtExportAlgorithm.exportSpectra(finalFile, spectra); } catch (Exception e) { MZmineGUI.displayMessage("Unable to export: " + e.getMessage()); e.printStackTrace(); } }).start(); }
From source file:acmi.l2.clientmod.xdat.Controller.java
@FXML private void saveAs() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Save"); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("XDAT (*.xdat)", "*.xdat"), new FileChooser.ExtensionFilter("All files", "*.*")); fileChooser.setInitialFileName(xdatFile.getValue().getName()); if (initialDirectory.getValue() != null && initialDirectory.getValue().exists() && initialDirectory.getValue().isDirectory()) fileChooser.setInitialDirectory(initialDirectory.getValue()); File file = fileChooser.showSaveDialog(editor.getStage()); if (file == null) return;//from ww w . java2s .c o m this.xdatFile.setValue(file); initialDirectory.setValue(file.getParentFile()); save(); }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
public void handleExportMSP(Event event) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export to MSP"); fileChooser.getExtensionFilters().add(new ExtensionFilter("NIST MSP format", "*.msp")); // Remember last directory if (lastSaveDirectory != null && lastSaveDirectory.isDirectory()) fileChooser.setInitialDirectory(lastSaveDirectory); // Show the file chooser File file = fileChooser.showSaveDialog(chartNode.getScene().getWindow()); // If nothing was chosen, quit if (file == null) return;// ww w . j a va 2 s. c om // Save the last open directory lastSaveDirectory = file.getParentFile(); final List<MsSpectrum> spectra = new ArrayList<>(); for (MsSpectrumDataSet dataset : datasets) { spectra.add(dataset.getSpectrum()); } // Do the export in a new thread final File finalFile = file; new Thread(() -> { try { MspExportAlgorithm.exportSpectra(finalFile, spectra); } catch (Exception e) { MZmineGUI.displayMessage("Unable to export: " + e.getMessage()); e.printStackTrace(); } }).start(); }