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


Java DirectoryChooser類代碼示例

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


DirectoryChooser類屬於javafx.stage包,在下文中一共展示了DirectoryChooser類的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: openDialogue

import javafx.stage.DirectoryChooser; //導入依賴的package包/類
private void openDialogue() {
    DirectoryChooser chooser = new DirectoryChooser();
    File file = chooser.showDialog(GuiData.getInstance().getStage());
    if (file != null) {
        try {
            FileData.getInstance().setWorkingFile(file);
            FXMLLoader loader = new FXMLLoader(FEFEditor.class.getResource("gui/fxml/fates/Dialogue.fxml"));
            content = loader.load();
            changeContent();
            Dialogue controller = loader.getController();
            controller.addAccelerators();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:thane98,項目名稱:FEFEditor,代碼行數:17,代碼來源:Selection.java

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

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

示例5: start

import javafx.stage.DirectoryChooser; //導入依賴的package包/類
@Override public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle("Simple Web Server");
    BorderPane root = new BorderPane();
    TextArea area = new TextArea();
    root.setCenter(area);
    ToolBar bar = new ToolBar();
    Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true);
    openInBrowser.setOnAction((event) -> {
        try {
            Desktop.getDesktop().browse(URI.create(webRoot));
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    Button changeRoot = FXUIUtils.createButton("fldr_closed", "Change Web Root", true);
    changeRoot.setOnAction((event) -> {
        DirectoryChooser chooser = new DirectoryChooser();
        File showDialog = chooser.showDialog(primaryStage);
        if (showDialog != null)
            server.setRoot(showDialog);
    });
    bar.getItems().add(openInBrowser);
    bar.getItems().add(changeRoot);
    root.setTop(bar);
    System.setOut(new PrintStream(new Console(area)));
    System.setErr(new PrintStream(new Console(area)));
    area.setEditable(false);
    primaryStage.setScene(new Scene(root));
    primaryStage.setOnShown((e) -> startServer(getParameters().getRaw()));
    primaryStage.show();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:32,代碼來源:SimpleWebServer.java

示例6: start

import javafx.stage.DirectoryChooser; //導入依賴的package包/類
@Override public void start(final Stage stage) {
    stage.setTitle("Directory Chooser Sample");

    final DirectoryChooser directoryChooser = new DirectoryChooser();
    final Button openButton = new Button("Select a folder...");

    openButton.setOnAction((final ActionEvent e) -> {
        File file = directoryChooser.showDialog(stage);
        if (file != null) {
            openFile(file);
        }
    });

    final GridPane inputGridPane = new GridPane();

    GridPane.setConstraints(openButton, 0, 1);
    inputGridPane.setHgap(6);
    inputGridPane.setVgap(6);
    inputGridPane.getChildren().addAll(openButton);

    final Pane rootGroup = new VBox(12);
    rootGroup.getChildren().addAll(inputGridPane);
    rootGroup.setPadding(new Insets(12, 12, 12, 12));

    stage.setScene(new Scene(rootGroup));
    stage.show();
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:28,代碼來源:DirectoryChooserSample.java

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

示例8: showDirectoryChooser

import javafx.stage.DirectoryChooser; //導入依賴的package包/類
public static File showDirectoryChooser(Scene scene) {
    String home = System.getProperty("user.home");
    File[] downloads = {
            new File(home + "/Downloads/"),
            new File(home + "/Загрузки/"),
            new File(home)
    };
    DirectoryChooser fileChooser = new DirectoryChooser();
    for (File download : downloads) {
        if (download.exists()) {
            fileChooser.setInitialDirectory(download);
            break;
        }
    }
    return fileChooser.showDialog(scene.getWindow());
}
 
開發者ID:KursX,項目名稱:Parallator,代碼行數:17,代碼來源:Helper.java

示例9: getInstallDir

import javafx.stage.DirectoryChooser; //導入依賴的package包/類
public static void getInstallDir(Predicate<File> predicate) throws IOException {
	ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
	URL fxmlUrl = classLoader.getResource("gui/install_location.fxml");
	if (fxmlUrl == null) {
		OneClientLogging.logger.error("An error has occurred loading the fxml!");
	}
	FXMLLoader fxmlLoader = new FXMLLoader();
	fxmlLoader.setLocation(fxmlUrl);
	fxmlLoader.setBuilderFactory(new JavaFXBuilderFactory());
	Parent root = fxmlLoader.load(fxmlUrl.openStream());
	Stage stage = new Stage();
	stage.setTitle("Select Install Location");
	stage.getIcons().add(new Image("images/icon.png"));
	stage.setResizable(false);
	stage.initOwner(Main.stage);
	stage.initModality(Modality.WINDOW_MODAL);
	Scene scene = new Scene(root, 500, 150);
	scene.getStylesheets().add("gui/css/theme.css");
	stage.setScene(scene);
	stage.show();
	InstallLocation controller = fxmlLoader.getController();
	controller.okButton.setOnAction(event -> {
		predicate.test(new File(controller.locationField.getText()));
		stage.close();
	});
	controller.browseButton.setOnAction(event -> {
		DirectoryChooser directoryChooser = new DirectoryChooser();
		File dir = new File(controller.locationField.getText());
		if (dir.exists())
			directoryChooser.setInitialDirectory(dir);
		File selectedDirectory = directoryChooser.showDialog(stage);
		if (selectedDirectory != null) {
			controller.locationField.setText(selectedDirectory.getAbsolutePath());
		}
	});
	controller.locationField.setText(Constants.getDefaultDir().getAbsolutePath());
}
 
開發者ID:HearthProject,項目名稱:OneClient,代碼行數:38,代碼來源:InstallLocation.java

示例10: pickAndReadAudioFilesFromFolder

import javafx.stage.DirectoryChooser; //導入依賴的package包/類
private void pickAndReadAudioFilesFromFolder(final Stage primaryStage, final VBox vboxPlaylist) {
    final DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Find a folder with audio files");
    final File selectedDirectory = directoryChooser.showDialog(primaryStage);
    if (selectedDirectory != null) {
        final File[] listFiles = selectedDirectory.listFiles();
        if (listFiles != null) {
            LOGGER.info("Found " + listFiles.length + " files");
            Arrays.stream(listFiles)
                    .filter(file -> !file.isDirectory())
                    .filter(file -> {
                        final String extension = FilenameUtils.getExtension(file.getPath());
                        return extension.equals(MP3) || extension.equals(M4A);
                    })
                    .forEach(file -> {
                        LOGGER.info("Trying to load from the file: " + file.getPath());
                        try {
                            readFileAndSetInitialStateForAudioItem(file, vboxPlaylist);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    });
        }
    }
}
 
開發者ID:Evegen55,項目名稱:main_carauto_board,代碼行數:26,代碼來源:AudioController.java

示例11: handleSelectFolder

import javafx.stage.DirectoryChooser; //導入依賴的package包/類
/**
 * Open a DirectoryChooser window.
 */
@FXML
private void handleSelectFolder() {
	final DirectoryChooser chooser = new DirectoryChooser();

	chooser.setTitle(Locale.getString("directory.chooser.title")); //$NON-NLS-1$

	if (!this.textAreaSaveDirectory.getText().isEmpty()) {
		final File defaultDirectory = new File(this.textAreaSaveDirectory.getText());
		if (defaultDirectory.exists()) {
			chooser.setInitialDirectory(defaultDirectory);
		}
	}

	final File selectedDirectory = chooser.showDialog(this.app.getPrimaryStage());

	if (selectedDirectory != null) {
		this.textAreaSaveDirectory.setText(selectedDirectory.toString());
	}
}
 
開發者ID:GamesRythmAnalysis,項目名稱:RNGames,代碼行數:23,代碼來源:MainWindowController.java

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

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

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

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


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