當前位置: 首頁>>代碼示例>>Java>>正文


Java DirectoryChooser.showDialog方法代碼示例

本文整理匯總了Java中javafx.stage.DirectoryChooser.showDialog方法的典型用法代碼示例。如果您正苦於以下問題:Java DirectoryChooser.showDialog方法的具體用法?Java DirectoryChooser.showDialog怎麽用?Java DirectoryChooser.showDialog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.stage.DirectoryChooser的用法示例。


在下文中一共展示了DirectoryChooser.showDialog方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: saveDirectory

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
@FXML private void saveDirectory() {
	try {
		BetonQuestEditor instance = BetonQuestEditor.getInstance();
		DirectoryChooser dc = new DirectoryChooser();
		dc.setTitle(instance.getLanguage().getString("select-directory"));
		File desktop = new File(System.getProperty("user.home") + File.separator + "Desktop");
		if (desktop != null) dc.setInitialDirectory(desktop);
		File selectedFile = dc.showDialog(instance.getPrimaryStage());
		if (selectedFile != null) {
			PackageSet set = BetonQuestEditor.getInstance().getDisplayedPackage().getSet();
			set.saveToDirectory(selectedFile);
			set.setSaveType(SaveType.DIR);
			set.setFile(selectedFile);
			MainMenuController.setSaveEnabled(true);
		}
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
開發者ID:Co0sh,項目名稱:BetonQuest-Editor,代碼行數:20,代碼來源:MainMenuController.java

示例2: addCharacter

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
@FXML
private void addCharacter() {
    DirectoryChooser chooser = new DirectoryChooser();
    File file = chooser.showDialog(GuiData.getInstance().getStage());
    if (file != null) {
        TextInputDialog dialog = new TextInputDialog("placeholder");
        dialog.setTitle("Name Input");
        dialog.setHeaderText("Name Input");
        dialog.setContentText("Please enter the voice set name:");

        Optional<String> result = dialog.showAndWait();
        result.ifPresent(name -> bin.addEntries(name, file));

        entryList.getItems().clear();
        groupList.getItems().clear();
        selectedEntry = null;
        selectedGroup = null;
        for (VoiceGroup v : bin.getEntries()) {
            groupList.getItems().add(v.getMainLabel());
        }
    }
}
 
開發者ID:thane98,項目名稱:FEFEditor,代碼行數:23,代碼來源:IndirectSound.java

示例3: handleOpenButtonAction

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
@FXML public void handleOpenButtonAction() {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle(Configuration.getBundle().getString("ui.menu.dialog.content.open.title"));
    File defaultDirectory;

    if(MainApp.getConfig().getWorkspaceFactory() == null){
        MainApp.getConfig().loadWorkspace();
    }
    defaultDirectory = new File(MainApp.getZdsutils().getOfflineContentPathDir());
    chooser.setInitialDirectory(defaultDirectory);
    File selectedDirectory = chooser.showDialog(MainApp.getPrimaryStage());

    if(selectedDirectory != null){
        File manifest = new File(selectedDirectory.getAbsolutePath() + File.separator + "manifest.json");
        ObjectMapper mapper = new ObjectMapper();
        Content content;
        try{
            content = mapper.readValue(manifest, Content.class);
            content.setRootContent(content, selectedDirectory.getAbsolutePath());
            mainApp.setContent(content);
            openContentWindow.close();
        }catch(IOException e){
            MainApp.getLogger().error(e.getMessage(), e);
        }
    }
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:27,代碼來源:OpenContent.java

示例4: selectStorageDirectory

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
@FXML
private void selectStorageDirectory() {
    Stage stage = (Stage) root.getScene().getWindow();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Open Telemetry Storage Directory");
    directoryChooser.setInitialDirectory(
            new File(System.getProperty("user.home")));
    File directory = directoryChooser.showDialog(stage);
    if (directory != null && directory.isDirectory()) {
        try {
            String directoryName = directory.getCanonicalPath();
            txtStorageDirectory.setText(directoryName);
        } catch (IOException e) {
            e.printStackTrace();
        }
    } 
}
 
開發者ID:SenorPez,項目名稱:project-cars-replay-enhancer-ui,代碼行數:18,代碼來源:PacketCaptureController.java

示例5: extractPDFOnClicked

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
@FXML
public void extractPDFOnClicked() {

    Stage primaryStage = new Stage();
    DirectoryChooser directoryChooser = new DirectoryChooser();
    File selectedDirectory
            = directoryChooser.showDialog(primaryStage);

    if (selectedDirectory == null) {

        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.setTitle("Warning");
        alert.setHeaderText("Look, an Information Dialog");
        alert.setContentText("You have not selected any directory!");
        alert.show();
    } else {

        getTables(selectedDirectory.getAbsolutePath());
    }
}
 
開發者ID:badarshahzad,項目名稱:SEGP_Group10,代碼行數:21,代碼來源:AllocatedPATsController.java

示例6: selectGameDirectory

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
/**
 * Selects a game directory for the profile editor
 */
@FXML private void selectGameDirectory() {
    DirectoryChooser chooser = new DirectoryChooser();
    if (this.gameDir.getText().isEmpty()) {
        chooser.setInitialDirectory(Constants.APPLICATION_WORKING_DIR);
    } else {
        File gd = new File(this.gameDir.getText());
        if (gd.isDirectory()) {
            chooser.setInitialDirectory(gd);
        } else {
            chooser.setInitialDirectory(Constants.APPLICATION_WORKING_DIR);
        }
    }
    File selectedFolder = chooser.showDialog(null);
    if (selectedFolder != null) {
        this.gameDir.setText(selectedFolder.getAbsolutePath());
    }
}
 
開發者ID:DarkLBP,項目名稱:Krothium-Launcher,代碼行數:21,代碼來源:MainFX.java

示例7: exportChunkAction

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
public void exportChunkAction() {
        Chunk chunk = (Chunk) chunksListView.getSelectionModel().getSelectedItem();
        if (chunk != null) {
//            FileChooser fileChooser = new FileChooser();
//            fileChooser.setTitle("Save File");
            DirectoryChooser directoryChooser = new DirectoryChooser();
            directoryChooser.setInitialDirectory(lastFileChooserPath);
            directoryChooser.setTitle("Choose directory");
            File dir = directoryChooser.showDialog(stage);
            if (dir != null) {
                try {
                    lastFileChooserPath = dir;
                    ObservableList<Chunk> chunks = chunksListView.getSelectionModel().getSelectedItems();
                    for (Chunk c : chunks) {
                        c.export(dir.getPath());
                    }
                } catch (IOException e) {
                    System.err.println(e.getMessage());
                }
            }
        }
    }
 
開發者ID:Polprzewodnikowy,項目名稱:KorgPackage,代碼行數:23,代碼來源:MainController.java

示例8: 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

示例9: 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

示例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:dmolony,項目名稱:dm3270,代碼行數:20,代碼來源:OptionStage.java

示例11: workingDirectorySupplier

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
private Path workingDirectorySupplier() {

        if (!Platform.isFxApplicationThread()) {
            final CompletableFuture<Path> completableFuture = new CompletableFuture<>();
            completableFuture.runAsync(() -> {
                threadService.runActionLater(() -> {
                    try {
                        Path path = workingDirectorySupplier();
                        completableFuture.complete(path);
                    } catch (Exception e) {
                        completableFuture.completeExceptionally(e);
                    }
                });
            }, threadService.executor());
            return completableFuture.join();
        }

        final DirectoryChooser directoryChooser = newDirectoryChooser("Select working directory");
        final File file = directoryChooser.showDialog(null);

        workingDirectory = Optional.ofNullable(file.toPath());

        workingDirectory.ifPresent(fileBrowser::browse);

        return Objects.nonNull(file) ? file.toPath() : null;
    }
 
開發者ID:asciidocfx,項目名稱:AsciidocFX,代碼行數:27,代碼來源:DirectoryService.java

示例12: choosePathButtonAction

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
/**
 * When the user presses the "..." button, a {@code DirectoryChooser} is opened where they can specify the
 * desired location for their new project file.
 */
@FXML private void choosePathButtonAction() {
    DirectoryChooser dirChooser = new DirectoryChooser();
    dirChooser.setTitle("Choose Project Location");

    File file = dirChooser.showDialog(MainWindow.getPrimaryStage());

    if (file != null) {
        String fileName = file.getPath();

        if (fileName.length() > MAX_FILE_NAME_LENGTH) {
            fileName = "..." + fileName.substring(fileName.length() - MAX_FILE_NAME_LENGTH);
        }

        setProjectLocation(file);
        pathTextField.setText(fileName);
    }
}
 
開發者ID:CIRDLES,項目名稱:Topsoil,代碼行數:22,代碼來源:ProjectTitleController.java

示例13: showDirectoryChooser

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
public static String showDirectoryChooser(String pathAsString, Window toOpenDialog) {
	DirectoryChooser chooser = new DirectoryChooser();
	chooser.setTitle("Choose your root directory");

	// if parent of given directory does exist, we open chooser with that location.
	// otherwise, take the user home as fallback.
	File path = new File(pathAsString).getParentFile();
	if(path.getParentFile().exists()) {
		chooser.setInitialDirectory(path.getParentFile());
	} else {
		chooser.setInitialDirectory(FileUtils.getUserDirectory());
	}

	try {
		File selectedDirectory = chooser.showDialog(toOpenDialog);
		if (selectedDirectory != null) {
			return selectedDirectory.getAbsolutePath();
		}
	} catch (IllegalArgumentException e) {
		SelectRootPathUtils.showInvalidDirectoryChooserEntryInformation();
		return pathAsString;
	}
	return pathAsString;
}
 
開發者ID:PeerWasp,項目名稱:PeerWasp,代碼行數:25,代碼來源:SelectRootPathUtils.java

示例14: printSSS

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
@FXML protected void printSSS(ActionEvent event) {
 if(shares == null || shares.size() == 0) {
	 GuiUtils.informationalAlert("Error !", "Make sure you split the wallet's seed and then print the pieces");
	 return;
 }
 
 DirectoryChooser dirChooser = new DirectoryChooser();
 dirChooser.setTitle("Save Pieces");
 File destination = dirChooser.showDialog(Main.startup);
 if(!destination.exists())
	 destination.mkdir();

 for(Share s: shares) {
	 try {
		PaperSSSController.createAndSavePaperSSS(s, walletSeed.getCreationTimeSeconds(), destination);
	} catch (IOException e) {
		e.printStackTrace();
		GuiUtils.informationalAlert("Error !", "Failed to print all the pieces.");
		return;
	}
 }
 
 GuiUtils.informationalAlert("Done !", "Saved all pieces to " + destination.getAbsolutePath() + "\n" +
		 							   "We suggest you give the pieces to close friends and family for safe keeping.");
}
 
開發者ID:BitcoinAuthenticator,項目名稱:Wallet,代碼行數:26,代碼來源:StartupController.java

示例15: chooseFileToSave

import javafx.stage.DirectoryChooser; //導入方法依賴的package包/類
private void chooseFileToSave() {
    String path;
    File selectedDirectory = null;

    Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
    alert.setTitle("Selectionner le dossier de sauvegarde");
    alert.setHeaderText("Veuillez selectionner le dossier dans lequel vous souhaitez effectuer la sauvegarde");

    ButtonType buttonTypeOne = new ButtonType("Selectionner");
    ButtonType buttonTypeDefault = new ButtonType("Par défaut");

    alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeDefault);

    Optional<ButtonType> result = alert.showAndWait();
    if (result.get() == buttonTypeOne) {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        selectedDirectory = directoryChooser.showDialog(primaryStage);
        path = selectedDirectory.getAbsolutePath() + "/parkingManager.ser";

    } else {
        path = "save/parkingManager.ser";
    }

    ParkingManagerSerializer.serialize(path);
    new Alert(Alert.AlertType.INFORMATION, "Parking sauvegardé !").show();
}
 
開發者ID:SKNZ,項目名稱:LesPatternsDuSwag,代碼行數:27,代碼來源:TopMenuBar.java


注:本文中的javafx.stage.DirectoryChooser.showDialog方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。