当前位置: 首页>>代码示例>>Java>>正文


Java DirectoryChooser.setInitialDirectory方法代码示例

本文整理汇总了Java中javafx.stage.DirectoryChooser.setInitialDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java DirectoryChooser.setInitialDirectory方法的具体用法?Java DirectoryChooser.setInitialDirectory怎么用?Java DirectoryChooser.setInitialDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.stage.DirectoryChooser的用法示例。


在下文中一共展示了DirectoryChooser.setInitialDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureDirectoryChooser

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
private static DirectoryChooser configureDirectoryChooser(File initDir) {
    // fileChooser.setTitle("View Pictures");
    DirectoryChooser dirChooser = new DirectoryChooser();
    if (initDir != null && initDir.exists()) {
        if (initDir.isDirectory()) {
            dirChooser.setInitialDirectory(initDir);
        } else {
            dirChooser.setInitialDirectory(initDir.getParentFile());
        }
    } else {
        dirChooser.setInitialDirectory(
                new File(System.getProperty("user.home")));
    }

    return dirChooser;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:17,代码来源:MainGuiController.java

示例2: exportAllGroups

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
public void exportAllGroups() {
    LOGGER.traceEntry();
    if (!isCatalogueLoaded()) {
        LOGGER.debug(":exportAllGroups - No catalogue set. Returning");
        return;
    }
    DirectoryChooser dc = new DirectoryChooser();
    if (manager.hasLastExportLocation()) {
        dc.setInitialDirectory(manager.getLastExportLocation());
    }
    dc.setTitle("Choose an export folder");
    File dir = dc.showDialog(evaluator.getScene().getWindow());

    for (Group g : manager.groupList()) {
        assemble(g);
    }

    manager.exportAllGroups(dir);
}
 
开发者ID:dbisUnibas,项目名称:ReqMan,代码行数:20,代码来源:EvaluatorHandler.java

示例3: openHandler

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
/**
 * Open repository.
 *
 * @param actionEvent event
 * @throws Exception
 */
public void openHandler(ActionEvent actionEvent) throws Exception {
    DirectoryChooser directoryChooser = new DirectoryChooser();
    if (GitemberApp.getSettingsService().getLastProject() != null) {
        directoryChooser.setInitialDirectory(new File(GitemberApp.getSettingsService().getLastProject()));
    }
    File selectedDirectory =
            directoryChooser.showDialog(GitemberApp.getMainStage());
    if (selectedDirectory != null) {
        String absPath = selectedDirectory.getAbsolutePath();
        if (!absPath.endsWith(Const.GIT_FOLDER)) {
            absPath += File.separator + Const.GIT_FOLDER;
        }
        openRepository(absPath);
    }
    createOpenRecentMenu();
}
 
开发者ID:iazarny,项目名称:gitember,代码行数:23,代码来源:FXMLController.java

示例4: onCmdChooseDirectorySource

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
@SuppressWarnings("unused")
@FXML
void onCmdChooseDirectorySource(ActionEvent evt) {
	DirectoryChooser chooser = new DirectoryChooser();

	chooser.setInitialDirectory(this.preferenceInitalDirectory.getValueAsFile());

	File directorySource = chooser.showDialog(getUI());

	if (directorySource != null) {
		this.ctlDirectorySourceInput.setText(directorySource.getAbsolutePath());
		this.preferenceInitalDirectory.putValueFromFile(directorySource);
		syncPreferences();
		validateAndReloadDirectorySource();
	}
}
 
开发者ID:hdecarne,项目名称:certmgr,代码行数:17,代码来源:CertImportController.java

示例5: showDirSaveDialog

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
public static File showDirSaveDialog(Window ownerWindow, File initDir, Consumer<DirectoryChooser> option) {
	DirectoryChooser chooser = new DirectoryChooser();
	chooser.setInitialDirectory(initDir);

	chooser.setTitle("Directory");
	if (option != null)
		option.accept(chooser);

	File selectedDir = chooser.showDialog(ownerWindow);
	if (selectedDir != null && selectedDir.exists()) {
		applyLastPath(selectedDir);
	}

	return selectedDir;

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:17,代码来源:DialogUtil.java

示例6: handleBrowse

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
private void handleBrowse(Event event) {
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Export Ort wählen");
    if (exportFolder != null) {
        directoryChooser.setInitialDirectory(new File(exportFolder));
    }
    File directory = directoryChooser.showDialog(null);

    if (directory == null || !directory.exists()) {
        getLogger().info("Invalid directory selected.");
        return;
    }

    directoryField.setText(directory.getPath());
    exportFolder = directory.getPath();
}
 
开发者ID:travelimg,项目名称:travelimg,代码行数:17,代码来源:ExportDialog.java

示例7: createRepo

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
public void createRepo(final Consumer<String> onOk) {
    final DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setInitialDirectory(new File(GitemberApp.getSettingsService().getUserHomeFolder()));
    final File selectedDirectory =
            directoryChooser.showDialog(GitemberApp.getMainStage());
    if (selectedDirectory != null) {
        String absPath = selectedDirectory.getAbsolutePath();
        try {
            GitemberApp.getRepositoryService().createRepository(absPath);
            String repoPath = absPath + File.separator + Const.GIT_FOLDER;
            log.log(Level.INFO, "New repository was created - " + absPath);
            onOk.accept(repoPath);
        } catch (Exception e) {
            log.log(Level.SEVERE, "Cannot create repository", e);
            GitemberApp.showException("Cannot create repository", e);
        }

    }
}
 
开发者ID:iazarny,项目名称:gitember,代码行数:20,代码来源:GitemberServiceImpl.java

示例8: chooseAndSetDirectory

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
/**
 * Opens directory chooser
 */
private void chooseAndSetDirectory() {
  DirectoryChooser fileChooser = new DirectoryChooser();
  fileChooser.setTitle(Util.text("choose-directory-window-name"));

  Session.DIRECTORY = !Settings.getSetting("path").isEmpty()
          ? new File(Settings.getSetting("path"))
          : null;
  fileChooser.setInitialDirectory(Session.DIRECTORY);

  File file;
  try {
    file = fileChooser.showDialog(stage);
  } catch (IllegalArgumentException ex) {
    fileChooser.setInitialDirectory(null);
    file = fileChooser.showDialog(stage);
  }

  if (file != null) {
    Session.DIRECTORY = file;
    browsePath.setText(file.getAbsolutePath());
    Settings.setSetting("path", Session.DIRECTORY.getAbsolutePath());
    getFileListByDirectory(file);
  }
}
 
开发者ID:yarl,项目名称:pattypan,代码行数:28,代码来源:ChooseDirectoryPane.java

示例9: handleExportMarkdownButtonAction

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
@FXML private void handleExportMarkdownButtonAction(ActionEvent event){
    Content content = mainApp.getContent();
    DirectoryChooser fileChooser = new DirectoryChooser();
    fileChooser.setInitialDirectory(MainApp.getDefaultHome());
    fileChooser.setTitle(Configuration.getBundle().getString("ui.dialog.export.dir.title"));
    File selectedDirectory = fileChooser.showDialog(MainApp.getPrimaryStage());
    File selectedFile = new File(selectedDirectory, ZdsHttp.toSlug(content.getTitle()) + ".md");
    log.debug("Tentative d'export vers le fichier " + selectedFile.getAbsolutePath());

    if(selectedDirectory != null){

        content.saveToMarkdown(selectedFile);
        log.debug("Export réussi vers " + selectedFile.getAbsolutePath());

        Alert alert = new CustomAlert(AlertType.INFORMATION);
        alert.setTitle(Configuration.getBundle().getString("ui.dialog.export.success.title"));
        alert.setHeaderText(Configuration.getBundle().getString("ui.dialog.export.success.header"));
        alert.setContentText(Configuration.getBundle().getString("ui.dialog.export.success.text")+" \"" + selectedFile.getAbsolutePath() + "\"");
        alert.setResizable(true);

        alert.showAndWait();
    }
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:24,代码来源:MenuController.java

示例10: editLocation

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
private void editLocation ()
{
  DirectoryChooser chooser = new DirectoryChooser ();
  chooser.setTitle ("Choose Spy Folder");
  File currentLocation = spyFolder.isEmpty () ? null : new File (spyFolder);
  if (currentLocation != null && currentLocation.exists ())
    chooser.setInitialDirectory (currentLocation);

  File selectedDirectory = chooser.showDialog (this);
  if (selectedDirectory != null)
  {
    spyFolder = selectedDirectory.getAbsolutePath ();
    fileComboBox.getItems ().clear ();
    ObservableList<String> files = getSessionFiles (spyFolder);
    fileComboBox.setItems (files);
    if (files.size () > 0)
      fileComboBox.getSelectionModel ().select (0);
  }
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:20,代码来源:OptionStage.java

示例11: setUTxFolder

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
/**
 * Sets and save ut path to xml user config file on click "Select"
 * 
 * @param utGame
 *            UT game to set path
 * @param utPathTxtField
 *            Textfield for path game display in settings
 */
private void setUTxFolder(UTGame utGame, TextField utPathTxtField) {

	DirectoryChooser chooser = new DirectoryChooser();
	chooser.setTitle("Select " + utGame.name + " folder");

	if (utPathTxtField != null && utPathTxtField.getText() != null && new File(utPathTxtField.getText()).exists()) {
		chooser.setInitialDirectory(new File(utPathTxtField.getText()));
	}

	if (utGame == UTGame.UT4) {
		chooser.setTitle("Select " + utGame.name + " editor folder");
	}

	File utxFolder = chooser.showDialog(new Stage());

	if (utxFolder != null) {
		utPathTxtField.setText(utxFolder.getAbsolutePath());
		saveGamePath(utPathTxtField, utGame);
	}
}
 
开发者ID:xtremexp,项目名称:UT4Converter,代码行数:29,代码来源:SettingsSceneController.java

示例12: browseForSave

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
@FXML
private void browseForSave() {
  DirectoryChooser dc = new DirectoryChooser();
  File destDir = new File(settingsProvider.getCodeGenerationSettings().getSaveDir());
  if (!Files.isDirectory(destDir.toPath())) {
    logger.warning("Loaded save directory does not exist, setting to default.");
    destDir = new File(CodeGenerationSettings.DEFAULT_SETTINGS.getSaveDir());
  }
  dc.setInitialDirectory(destDir);
  dc.setTitle("Choose save location");
  File save = dc.showDialog(optionsGrid.getScene().getWindow());
  if (save == null) {
    return;
  }
  saveLocationLabel.setText(save.getAbsolutePath());
}
 
开发者ID:WPIRoboticsProjects,项目名称:GRIP,代码行数:17,代码来源:CodeGenerationOptionsController.java

示例13: showJavaSingleDirectoryChooser

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
/**
 * Show Java's {@link DirectoryChooser} window that allows the user to choose a single
 * directory.
 * <p>
 * Internally it automatically opens last opened directory, lets the user to choose a new
 * directory, sets TextField (provided as argument in this method) to this directory's path and
 * remembers this directory.
 * 
 * @param title
 *            The title of window to show.
 * @param tfToSet
 *            The TextField to set after the user has chosen the directory.
 */
public static void showJavaSingleDirectoryChooser(String title, TextField tfToSet) {
	Window window = tfToSet.getScene().getWindow();
	DirectoryChooser dirChooser = new DirectoryChooser();
	dirChooser.setTitle(title);
	String lastDir = CuteConfig.getString(CuteConfig.UTILGUI, "LastFileDirectory");
	if (Util.checkDirectory(lastDir)) {
		dirChooser.setInitialDirectory(new File(lastDir));
	}
	File file = null;
	file = dirChooser.showDialog(window);
	if (file != null) {
		CuteConfig.setString(CuteConfig.UTILGUI, "LastFileDirectory",
				file.getAbsolutePath());
		tfToSet.setText(file.getAbsolutePath());
	}
}
 
开发者ID:ubershy,项目名称:StreamSis,代码行数:30,代码来源:GUIUtil.java

示例14: onBrowseForTargetDirectory

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
private void onBrowseForTargetDirectory() {
    final StringBuilder chooserTitle = new StringBuilder("Choose where to download '");
    chooserTitle.append(metaData.getName());
    chooserTitle.append("' to:");

    final DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setInitialDirectory(new File(System.getProperty("user.home")));
    directoryChooser.setTitle(chooserTitle.toString());

    final File selectedDirectory = directoryChooser.showDialog(window.getOwner());

    if(selectedDirectory != null) {
        final String selectedTargetDirectory = selectedDirectory.getAbsolutePath();
        if(!savePathCombo.getItems().contains(selectedTargetDirectory)) {
            savePathCombo.getItems().add(selectedTargetDirectory);
        }
        savePathCombo.getSelectionModel().select(selectedTargetDirectory);
    }
}
 
开发者ID:veroslav,项目名称:jfx-torrent,代码行数:20,代码来源:AddTorrentWindow.java

示例15: onSelectOutputDirClicked

import javafx.stage.DirectoryChooser; //导入方法依赖的package包/类
@FXML
void onSelectOutputDirClicked(ActionEvent event) {
	DirectoryChooser directoryChooser = new DirectoryChooser();
	directoryChooser.setTitle(i18nBundle.getString("app.dialog.select_output_dir.title"));
	File initialDirectory = new File(System.getProperty("user.home"));
	if(inputFilePath != null) {
    	File inputFile = new File(inputFilePath);
    	if(inputFile.exists()) {
    		initialDirectory = inputFile.getParentFile();
    	}
	}
	directoryChooser.setInitialDirectory(initialDirectory);
	File dir = directoryChooser.showDialog(this);
	if(dir != null) {
		outputDirPath = dir.getPath();
		outputDirTextField.setText(outputDirPath);
		updateBottomStatus(STATUS.DIR_PREPARED);
	}
}
 
开发者ID:liudonghua123,项目名称:signapk_fx,代码行数:20,代码来源:MainPaneController.java


注:本文中的javafx.stage.DirectoryChooser.setInitialDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。