本文整理汇总了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);
}
}
示例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());
}
}
}
示例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);
}
}
}
示例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();
}
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
}
}
示例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);
}
}
示例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());
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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.");
}
示例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();
}