List of usage examples for javafx.stage DirectoryChooser DirectoryChooser
DirectoryChooser
From source file:org.beryx.viewreka.fxapp.ProjectBasicInfo.java
public void chooseProjectDir() { DirectoryChooser dirChooser = new DirectoryChooser(); dirChooser.setTitle("New Project Directory"); GuiSettings guiSettings = guiSettingsManager.getSettings(); dirChooser.setInitialDirectory(guiSettings.getMostRecentProjectDir()); File projectDir = dirChooser.showDialog(getScene().getWindow()); if (projectDir != null && projectDir.isDirectory()) { txtNewProjectDir.setText(projectDir.getAbsolutePath()); String prjName = toProjectName(projectDir.getName()); if (isProjectNameValid(prjName)) { txtNewProjectName.setText(prjName); }//w w w .j av a 2s . c o m } }
From source file:deincraftlauncher.InstallController.java
@FXML void onChangePath(ActionEvent event) { System.out.println("changing Path..."); DirectoryChooser fileChooser = new DirectoryChooser(); fileChooser.setInitialDirectory(defaultInstall); fileChooser.setTitle("Whle Installationsort"); File chosen = fileChooser.showDialog(deincraftlauncher.DeincraftLauncherUI.window); if (chosen != null) { String choosed = chosen.toString(); System.out.println("Chosen Path: " + choosed); targetPath = choosed + File.separator + "Minefactory" + File.separator; pathLabel.setText(targetPath);//from w ww.ja v a 2 s.co m } else { System.out.println("pathchange cancelled"); } //fileChooser.showOpenDialog(deincraftlauncher.DeincraftLauncherUI.window); }
From source file:condorclient.CreateJobDialogController.java
@FXML private void resultDirChooserFired(ActionEvent event) { DirectoryChooser dirChooser = new DirectoryChooser(); dirChooser.setTitle(""); String cwd = System.getProperty("user.home"); dirChooser.setInitialDirectory(new File(cwd)); File chosenDir = dirChooser.showDialog(this.stage); // File chosenDir = chooser.showDialog(primaryStage); if (chosenDir != null) { resultFileText.setText(chosenDir.getAbsolutePath()); System.out.println(chosenDir.getAbsolutePath()); } else {//from w ww . jav a2s .c om System.out.print("no directory chosen"); } resultOk = true; enableButton(); }
From source file:uk.co.everywheremusic.viewcontroller.SetupScene.java
private void startSetupWindow(Stage primaryStage) { try {/* w ww.j a va 2s. co m*/ installFolder = new File(".").getCanonicalPath() + Globals.INSTALL_EXT; } catch (IOException ex) { Logger.getLogger(SetupScene.class.getName()).log(Level.SEVERE, null, ex); installFolder = System.getProperty("user.dir") + Globals.INSTALL_EXT; } primaryStage.setTitle(Globals.APP_NAME); grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); column1 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column1.setHgrow(Priority.ALWAYS); column2 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column2.setHgrow(Priority.ALWAYS); column3 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column3.setHgrow(Priority.ALWAYS); column4 = new ColumnConstraints(100, 100, Double.MAX_VALUE); column4.setHgrow(Priority.ALWAYS); grid.getColumnConstraints().addAll(column1, column2, column3, column4); sceneTitle = new Label(Globals.SETUP_FRAME_TITLE); sceneTitle.setId(Globals.CSS_TITLE_ID); sceneTitle.setPrefWidth(Double.MAX_VALUE); sceneTitle.setAlignment(Pos.CENTER); ImageView imageView = null; try { imageView = new ImageView(); String img = new File(Globals.IC_LOGO).toURI().toURL().toString(); imgLogo = new Image(img); imageView.setImage(imgLogo); } catch (MalformedURLException ex) { Logger.getLogger(ServerScene.class.getName()).log(Level.SEVERE, null, ex); } GridPane titlePane = new GridPane(); ColumnConstraints c1 = new ColumnConstraints(50); ColumnConstraints c2 = new ColumnConstraints(400); titlePane.getColumnConstraints().addAll(c1, c2); titlePane.add(imageView, 0, 0); titlePane.add(sceneTitle, 1, 0); titlePane.setAlignment(Pos.CENTER); grid.add(titlePane, 0, 0, 4, 1); lblFolder = new Label(Globals.SETUP_LBL_MUSIC_FOLDER); grid.add(lblFolder, 0, 2, 3, 1); txtFolder = new TextField(); txtFolder.setText("/home/kyle/Music/Test music"); grid.add(txtFolder, 0, 3, 3, 1); btnFolder = new Button(Globals.SETUP_BTN_MUSIC_FOLDER); btnFolder.setPrefWidth(Double.MAX_VALUE); grid.add(btnFolder, 3, 3); final DirectoryChooser dirChooser = new DirectoryChooser(); btnFolder.setOnAction((ActionEvent event) -> { File dir = dirChooser.showDialog(primaryStage); if (dir != null) { txtFolder.setText(dir.getAbsolutePath()); } }); lblPassword = new Label("Choose a password:"); grid.add(lblPassword, 0, 4, 2, 1); lblConfirmPassword = new Label("Confirm your password:"); grid.add(lblConfirmPassword, 2, 4, 2, 1); txtPassword = new PasswordField(); grid.add(txtPassword, 0, 5, 2, 1); txtConfirmPassword = new PasswordField(); grid.add(txtConfirmPassword, 2, 5, 1, 1); textArea = new TextArea(); textArea.setPrefHeight(Double.MAX_VALUE); textArea.setDisable(true); textArea.setWrapText(true); grid.add(textArea, 0, 7, 4, 2); StackPane progressPane = new StackPane(); lblProgress = new Label(Globals.SETUP_LBL_PERCENT); lblProgress.setId(Globals.CSS_PROGBAR_LBL_ID); lblProgress.setVisible(false); progressBar = new ProgressBar(0); progressBar.setPrefWidth(Double.MAX_VALUE); progressBar.setVisible(false); progressPane.getChildren().addAll(progressBar, lblProgress); progressPane.setAlignment(Pos.CENTER_RIGHT); grid.add(progressPane, 0, 11, 3, 1); StackPane buttonPane = new StackPane(); btnInstall = new Button(Globals.SETUP_BTN_INSTALL); btnInstall.setPrefWidth(Double.MAX_VALUE); btnDone = new Button(Globals.SETUP_BTN_DONE); btnDone.setPrefWidth(Double.MAX_VALUE); btnDone.setVisible(false); buttonPane.getChildren().addAll(btnInstall, btnDone); grid.add(buttonPane, 3, 11); btnInstall.setOnAction((ActionEvent event) -> { boolean valid = validateForm(); if (valid) { lblFolder.setDisable(true); txtFolder.setDisable(true); btnFolder.setDisable(true); lblPassword.setDisable(true); txtPassword.setDisable(true); lblConfirmPassword.setDisable(true); txtConfirmPassword.setDisable(true); textArea.setDisable(false); lblProgress.setVisible(true); progressBar.setVisible(true); btnInstall.setDisable(true); musicFolder = txtFolder.getText(); password = txtPassword.getText(); setupWorker = createSetupWorker(); progressBar.progressProperty().unbind(); progressBar.progressProperty().bind(setupWorker.progressProperty()); setupWorker.messageProperty().addListener( (ObservableValue<? extends String> observable, String oldValue, String newValue) -> { String[] values = newValue.split("\\|"); lblProgress.setText(values[0] + "%"); textArea.appendText(values[1] + "\n"); if (values[1].equals(Globals.SETUP_MSG_DONE)) { btnInstall.setVisible(false); btnDone.setVisible(true); } }); new Thread(setupWorker).start(); } }); btnDone.setOnAction((ActionEvent event) -> { primaryStage.hide(); new ServerScene(installFolder, musicFolder).showWindow(new Stage()); }); try { String imgUrl = new File(Globals.IC_LOGO).toURI().toURL().toString(); javafx.scene.image.Image i = new javafx.scene.image.Image(imgUrl); primaryStage.getIcons().add(i); } catch (MalformedURLException ex) { Logger.getLogger(ServerScene.class.getName()).log(Level.SEVERE, null, ex); } scene = new Scene(grid, 600, 400); primaryStage.setScene(scene); scene.getStylesheets().add(SetupScene.class.getResource(Globals.CSS_FILE).toExternalForm()); // grid.setGridLinesVisible(true); primaryStage.show(); }
From source file:analyzer.code.FXMLAnalyzerController.java
@FXML private void openProjectMenuItem() throws FileNotFoundException, IOException { source.clear();/*from w ww . j a v a 2 s . c o m*/ DirectoryChooser chooser = new DirectoryChooser(); chooser.setTitle("C project"); File selectedDirectory = chooser.showDialog(null); if (null != selectedDirectory) { File[] files = selectedDirectory.listFiles(); for (File file : files) { if (FilenameUtils.getExtension(file.getAbsolutePath()).equals("java")) { analyzer = new AnalyzerC(); curLang = C; countOperatorsEnable = true; levelNestEnable = true; middleLenIdentEnable = true; tableMetric.setVisible(true); tableDescript.setVisible(true); labelDesc.setVisible(true); labelMetrics.setVisible(true); button.setVisible(true); Scanner scanner = new Scanner(file); nameFile.add(FilenameUtils.getName(file.getAbsolutePath())); String tmpSource = new String(); while (scanner.hasNext()) { tmpSource += scanner.nextLine() + '\n'; } source.add(tmpSource); } } } }
From source file:ch.unibas.fittingwizard.presentation.MoleculeListPage.java
public void handleLoadExisting(ActionEvent event) { logger.info("Loading existing molecule."); DirectoryChooser chooser = new DirectoryChooser(); chooser.setInitialDirectory(moleculeDir.getDirectory()); chooser.setTitle("Please select a molecule."); File selectedDir = chooser.showDialog(this.getScene().getWindow()); if (selectedDir == null) { logger.info("User skipped."); return;//from w ww. j a va2s . c o m } String moleculeName = selectedDir.getName(); if (moleculeRepository.checkIfExists(new MoleculeId(moleculeName))) { logger.info("Molecule already loaded."); OverlayDialog.informUser("Molecule already loaded!", "The selected molecule was already loaded. Please select another molecule."); return; } File xyzFile = new File(selectedDir.getParentFile(), moleculeName + ".xyz"); if (!xyzFile.isFile()) { logger.error("XYZ file not found. Skipping."); String format = String.format("No xyz file (%s) found for selected molecule %s.", xyzFile.getAbsolutePath(), moleculeName); OverlayDialog.showError("Could not load molecule", format); return; } xyzFile = copyFilesToMoleculesDir(selectedDir, xyzFile); XyzFile parse = null; try { parse = XyzFileParser.parse(xyzFile); } catch (Exception e) { OverlayDialog.showError("Could not load molecule", "Error while parsing the xyz file " + xyzFile.getAbsolutePath()); } navigateTo(AtomTypeChargePage.class, new AtomChargesDto(parse)); }
From source file:dsfixgui.FileIO.DSFixFileController.java
public void chooseDataFolder() { DirectoryChooser dirPicker = new DirectoryChooser(); dirPicker.setTitle(DIALOG_TITLE_PICK_DIR); if (ui.getDataFolder() != null && ui.getDataFolder().exists()) { dirPicker.setInitialDirectory(ui.getDataFolder()); }//from w w w .j a va2s . c o m File newDataFolder = dirPicker.showDialog(ui.getStage()); if (newDataFolder != null && newDataFolder.exists()) { //Check for DARKSOULS.exe File dsExe = new File(newDataFolder.getPath() + "\\" + DS_EXE); if (!dsExe.exists()) { //Make sure they didn't pick the parent folder by accident dsExe = new File(newDataFolder.getPath() + DATA_FOLDER + "\\" + DS_EXE); if (!dsExe.exists()) { AlertDialog dsExeNotFound = new AlertDialog(300.0, 80.0, DIALOG_TITLE_NO_DS_EXE, DIALOG_MSG_NO_DS_EXE, DIALOG_BUTTON_TEXTS[0]); } else { ui.setDataFolder(newDataFolder.getPath() + DATA_FOLDER); return; } } ui.setDataFolder(newDataFolder.getPath()); } }
From source file:com.mycompany.trafficimportfileconverter2.Main2Controller.java
/** * Initializes the controller class./* w w w .j a v a 2 s. c o m*/ */ @Override public void initialize(URL url, ResourceBundle rb) { prefs = Preferences.userNodeForPackage(this.getClass()); initDateArrays(); dirchooser = new DirectoryChooser(); outputDir.addListener(new ChangeListener<File>() { @Override public void changed(ObservableValue<? extends File> observable, File oldValue, File newValue) { lblOutputLoc.setText(newValue.getAbsolutePath()); prefs.put(OUTPUT_DIR_LOC, newValue.getAbsolutePath()); } }); setOutputDir(safeFileSet(new File(prefs.get(OUTPUT_DIR_LOC, "./")))); try { dirchooser.setInitialDirectory(getOutputDir()); } catch (Exception e) { System.out.println("Error setting init dir: " + e); e.printStackTrace(); } filechooser = new FileChooser(); try { filechooser.setInitialDirectory(new File(prefs.get(INPUT_DIR_LOC, "./"))); } catch (Exception e) { System.out.println("Error setting init directory of file chooser: " + e); e.printStackTrace(); } setExtension(prefs.get(EXTENSION, ".gen")); /* Save in preferences default getting file location every time the input file is reselected. */ inputFile.addListener(new ChangeListener<File>() { @Override public void changed(ObservableValue<? extends File> observable, File oldValue, File newValue) { lblInputFile.setText(newValue.getAbsolutePath()); prefs.put(INPUT_DIR_LOC, newValue.getParent()); reloadFileData(newValue); } }); txtAreaOutput.textProperty().addListener(new ChangeListener<Object>() { @Override public void changed(ObservableValue<?> observable, Object oldValue, Object newValue) { txtAreaOutput.setScrollTop(Double.MAX_VALUE); //this will scroll to the bottom //use Double.MIN_VALUE to scroll to the top } }); filechooser.getExtensionFilters().add(new ExtensionFilter("Tab Separated Values", "*.tsv", "*.TSV")); autoSearch(); log("Help document located:"); log(helpurl); }
From source file:dpfmanager.shell.interfaces.gui.component.dessign.DessignController.java
public void selectInputAction() { String txtFile = null;/* ww w. j a v a 2 s . c o m*/ ComboBox c = getView().getComboChoice(); String configDir = DPFManagerProperties.getDefaultDirFile(); if (c.getValue().equals(getBundle().getString("comboFile"))) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(getBundle().getString("openFile")); fileChooser.setInitialDirectory(new File(configDir)); fileChooser.getExtensionFilters().addAll(generateExtensionsFilters()); List<File> files = fileChooser.showOpenMultipleDialog(GuiWorkbench.getMyStage()); if (files != null) { String sfiles = ""; File last = null; for (File file : files) { if (sfiles.length() > 0) sfiles += ";"; sfiles += file.getPath(); last = file; } txtFile = sfiles; if (last.exists() && last.getParent() != null && last.getParentFile().exists() && last.getParentFile().isDirectory()) { String path = last.getParent(); DPFManagerProperties.setDefaultDirFile(path); } } } else if (c.getValue().equals(getBundle().getString("comboFolder"))) { DirectoryChooser folderChooser = new DirectoryChooser(); folderChooser.setTitle(getBundle().getString("openFolder")); folderChooser.setInitialDirectory(new File(configDir)); File directory = folderChooser.showDialog(GuiWorkbench.getMyStage()); if (directory != null) { txtFile = directory.getPath(); DPFManagerProperties.setDefaultDirFile(directory.getPath()); } } if (txtFile != null) { getView().getInputText().setText(txtFile); } }
From source file:caillou.company.clonemanager.gui.customComponent.location.LocationController.java
@FXML private void handleFilechooserAction(ActionEvent event) { DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setTitle(SpringFxmlLoader.getResourceBundle().getString("title.selectDirectory")); File file = directoryChooser.showDialog(null); if (file != null) { path.setText(file.getAbsolutePath()); }// w w w . j av a 2s . c om }