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


Java FileChooser.showOpenMultipleDialog方法代碼示例

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


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

示例1: selectForJoinTwoPrawnFiles

import javafx.stage.FileChooser; //導入方法依賴的package包/類
public static List<File> selectForJoinTwoPrawnFiles(Window ownerWindow)
        throws IOException, JAXBException, SAXException {
    List<File> retVal = new ArrayList<>();

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select Two Prawn XML files");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Prawn XML files", "*.xml"));
    File initDirectory = new File(squidPersistentState.getMRUPrawnFileFolderPath());
    fileChooser.setInitialDirectory(initDirectory.exists() ? initDirectory : null);

    List<File> prawnXMLFilesNew = fileChooser.showOpenMultipleDialog(ownerWindow);

    if (prawnXMLFilesNew != null) {
        if ((prawnXMLFilesNew.size() == 2)
                && prawnXMLFilesNew.get(0).getName().toLowerCase(Locale.US).endsWith(".xml")
                && prawnXMLFilesNew.get(1).getName().toLowerCase(Locale.US).endsWith(".xml")) {
            retVal = prawnXMLFilesNew;
        } else {
            throw new IOException("Please choose exactly 2 Prawn xml files to merge.");
        }
    }

    return retVal;
}
 
開發者ID:CIRDLES,項目名稱:Squid,代碼行數:25,代碼來源:FileHandler.java

示例2: handleButtonBrowseMedtronic

import javafx.stage.FileChooser; //導入方法依賴的package包/類
@FXML
private void handleButtonBrowseMedtronic(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_MEDTRONIC_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.CSV_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        medtronicTextField.setText(sb.toString().substring(0, sb.length() - 1));
        medtronicCheckBox.setSelected(true);
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:19,代碼來源:MainGuiController.java

示例3: handleButtonBrowseAbbott

import javafx.stage.FileChooser; //導入方法依賴的package包/類
@FXML
private void handleButtonBrowseAbbott(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_ABBOTT_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.TXT_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        abbottTextField.setText(sb.toString().substring(0, sb.length() - 1));
        abbottCheckBox.setSelected(true);
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:19,代碼來源:MainGuiController.java

示例4: handleButtonBrowseGoogleFit

import javafx.stage.FileChooser; //導入方法依賴的package包/類
@FXML
private void handleButtonBrowseGoogleFit(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_GOOGLE_FIT_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.CSV_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        googleFitTextField.setText(sb.toString().substring(0, sb.length() - 1));
        googleFitCheckBox.setSelected(true);
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:19,代碼來源:MainGuiController.java

示例5: handleButtonBrowseGoogleTracks

import javafx.stage.FileChooser; //導入方法依賴的package包/類
@FXML
private void handleButtonBrowseGoogleTracks(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_GOOGLE_TRACKS_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.JSON_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        googleGatheredTextField.setText(sb.toString().substring(0, sb.length() - 1));
        googleGatheredCheckBox.setSelected(true);
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:19,代碼來源:MainGuiController.java

示例6: handleButtonBrowseRoche

import javafx.stage.FileChooser; //導入方法依賴的package包/類
@FXML
private void handleButtonBrowseRoche(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_ROCHE_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.CSV_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        sonyTextField.setText(sb.toString().substring(0, sb.length() - 1));
        sonyCheckBox.setSelected(true);
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:19,代碼來源:MainGuiController.java

示例7: handleButtonBrowseOpenDiabetesVault

import javafx.stage.FileChooser; //導入方法依賴的package包/類
@FXML
private void handleButtonBrowseOpenDiabetesVault(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_ODV_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.JSON_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        odvTextField.setText(sb.toString().substring(0, sb.length() - 1));
        odvCheckBox.setSelected(true);
    }
}
 
開發者ID:tiweGH,項目名稱:OpenDiabetes,代碼行數:19,代碼來源:MainGuiController.java

示例8: loadPlugin

import javafx.stage.FileChooser; //導入方法依賴的package包/類
@FXML
private void loadPlugin() {
  FileChooser chooser = new FileChooser();
  chooser.setTitle("Choose a plugin");
  chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Plugin", "*.jar"));
  List<File> files = chooser.showOpenMultipleDialog(root.getScene().getWindow());
  if (files == null) {
    return;
  }
  files.forEach(f -> {
    try {
      // TODO save this in user preferences
      PluginLoader.getDefault().loadPluginJar(f.toURI());
    } catch (IOException | IllegalArgumentException e) {
      log.log(Level.WARNING, "Could not load jar", e);
      // TODO improve the dialog; use something like what GRIP has
      Alert alert = new Alert(Alert.AlertType.ERROR, null, ButtonType.OK);
      alert.setTitle("Could not load plugins");
      alert.setHeaderText("Plugins in " + f.getName() + " could not be loaded");
      alert.setContentText("Error message:\n\n    " + e.getMessage());
      alert.showAndWait();
    }
  });
}
 
開發者ID:wpilibsuite,項目名稱:shuffleboard,代碼行數:25,代碼來源:PluginPaneController.java

示例9: selectmultifiles

import javafx.stage.FileChooser; //導入方法依賴的package包/類
public void selectmultifiles(ActionEvent event) {
	FileChooser fc = new FileChooser();
//	fc.setInitialDirectory(new File("C:\\PdfBox_Examples"));
	fc.getExtensionFilters().addAll(new ExtensionFilter("PDF Files", "*.pdf"));
	selectedFiles = fc.showOpenMultipleDialog(null);

	// FIX - Repeating files in list if ReADDED

	if (selectedFiles != null) {
		for (int i = 0; i < selectedFiles.size(); i++) {
			fileslist.getItems().add(selectedFiles.get(i).getAbsolutePath());
			mylist.add(selectedFiles.get(i).getAbsolutePath());
			NOOFFILES++;
		}
	} else {
		// Provide Error in window
		System.out.println("Invalid File");
	}
}
 
開發者ID:djdivix,項目名稱:IDBuilderFX,代碼行數:20,代碼來源:MultiFileChooserController.java

示例10: handleOpenGroups

import javafx.stage.FileChooser; //導入方法依賴的package包/類
public void handleOpenGroups(ActionEvent actionEvent) {
    if (!manager.isCatalogueLoaded()) {
        return;
    }
    FileChooser fc = Utils.createGroupFileChooser("Open");
    if (manager.hasLastOpenLocation()) {
        fc.setInitialDirectory(manager.getLastOpenLocation());
    }
    List<File> files = fc.showOpenMultipleDialog(evaluator.getScene().getWindow());
    if (files == null) {
        return; // USER ABORT
    }
    if (files.size() == 1) {
        if (!manager.isAnyGroupFilePresent(files).isEmpty()) {
            Utils.showErrorDialog("Duplicate group files", "Cannot open a group twice");
            return;
        }
        manager.openGroup(files.get(0), (g) -> {
            handleFirstGroupPresent();
            loadGroupUI(g);
        }, this::handleOpenGroupException);

    } else if (files.size() >= 2) {
        List<File> dupes = manager.isAnyGroupFilePresent(files);
        List<File> noDupes = new ArrayList<>(files);
        noDupes.removeAll(dupes);
        manager.openGroups(noDupes, (list) -> {
            loadGroupUI(list);
            handleFirstGroupPresent();
        }, this::handleOpenGroupException);
    }
    // USER ABORT
}
 
開發者ID:dbisUnibas,項目名稱:ReqMan,代碼行數:34,代碼來源:EvaluatorHandler.java

示例11: handleMenuActionImportCode

import javafx.stage.FileChooser; //導入方法依賴的package包/類
public void handleMenuActionImportCode() {
    final FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser);
    List<File> list = fileChooser.showOpenMultipleDialog(stage);
    if (list != null) {
        for (File file : list) {
            saveFile(file);
        }
    }
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:11,代碼來源:TabController.java

示例12: openFiles

import javafx.stage.FileChooser; //導入方法依賴的package包/類
/**
 * <h1>Lets the user choose a file / files to load.</h1>
 * Distinguishes which filetype is about to be loaded by the user
 * and calls the associated methods.
 *
 * @param fileType Enum to differentiate which type of file is loaded by the user.
 */
private void openFiles(FileType fileType) {
    FileChooser fileChooser = new FileChooser();
    String fileChooserTitle = "Load from ";

    if ((Boolean) UserSettings.userSettings.get("isDefaultFileChooserLocation")) {
        setDefaultOpenDirectory(fileChooser);
    } else {
        fileChooser.setInitialDirectory(new File((String) UserSettings.userSettings.get("defaultFileChooserLocation")));
    }

    switch (fileType) {
        case taxonId2Count:
            fileChooser.setTitle(fileChooserTitle + "taxonId2Count file");
            break;
        case readName2TaxonId:
            fileChooser.setTitle(fileChooserTitle + "readName2TaxonId file");
            break;
        case biomV1:
            fileChooser.setTitle(fileChooserTitle + "biomV1 file");
            break;
        case biomV2:
            fileChooser.setTitle(fileChooserTitle + "biomV2 file");
            break;
        case qiime:
            fileChooser.setTitle(fileChooserTitle + "qiime file");
            break;
    }

    //Choose the file / files

    List<File> selectedFiles = fileChooser.showOpenMultipleDialog(getPrimaryStage());

    if (selectedFiles != null) {
        //Keeps every file that has been loaded before in a list to show only one alert
        //for multiple files
        ArrayList<String> namesOfAlreadyLoadedFiles = new ArrayList<>();
        for (File file : selectedFiles) {
            String foundFilePath = file.getAbsolutePath();
            if (LoadedData.getOpenFiles() != null && LoadedData.getOpenFiles().contains(foundFilePath)) {
                namesOfAlreadyLoadedFiles.add(file.getName());
            } else {
                switch (fileType) {
                    case taxonId2Count:
                        addId2CountFileToTreeView(file);
                        break;
                    case readName2TaxonId:
                        addReadName2TaxonIdFileToTreeView(file);
                        break;
                    case biomV1:
                        addBiomV1FileToTreeView(file);
                        break;
                    case biomV2:
                        addBiomV2FileToTreeView(file);
                        break;
                    case qiime:
                        //TODO HANDLE METADATA PROVIDED BY QIIME
                        break;
                }
            }
        }
        //Shows an alert if the user chose to load one or multiple files
        //that have already been loaded before.
        if (namesOfAlreadyLoadedFiles.size() != 0) {
            showFileAlreadyLoadedAlert(namesOfAlreadyLoadedFiles);
        }
    }


}
 
開發者ID:jmueller95,項目名稱:CORNETTO,代碼行數:77,代碼來源:MainStageController.java

示例13: buttonsHandler

import javafx.stage.FileChooser; //導入方法依賴的package包/類
public void buttonsHandler(ActionEvent event) {
    switch (((Button) event.getSource()).getId()) {
        case "picker"://ファイル取得
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("Open Resource File");
            File userDirectory = new File("." + File.separator + SOUTAI_FILE);
            fileChooser.setInitialDirectory(userDirectory);

            fileChooser.getExtensionFilters().add(
                    new FileChooser.ExtensionFilter("All Files", "*.*"));
            List<File> selectedFile = fileChooser.showOpenMultipleDialog(mainpage.getScene().getWindow());
            if (selectedFile != null) {
                for (int i = 0; i < selectedFile.size(); i++) {
                    if (isTextFile(selectedFile.get(i).getAbsolutePath()))
                        fileList.getItems().add(new Label(selectedFile.get(i).getAbsolutePath()));

                }
            }
            break;
        case "clear"://一覧削除
            while (!fileList.getItems().isEmpty()) fileList.getItems().remove(0);
            break;
        case "generate":
            List<String> pathList = new ArrayList<>();
            fileList.getItems().forEach(s -> pathList.add(((Label) s).getText()));
            createDocument(pathList);
            break;
        case "folderPicker"://フォルダ選択
            DirectoryChooser directoryChooser = new DirectoryChooser();
            directoryChooser.setTitle("Open Resource File");
            directoryChooser.setInitialDirectory(new File("." + File.separator + SOUTAI_FILE));

            File selectedFolder = directoryChooser.showDialog(mainpage.getScene().getWindow());
            List<String> filePathList = new ArrayList<>();
            getFileRecursion(filePathList, selectedFolder.getAbsolutePath()).stream().filter(s -> isTextFile(s)).collect(Collectors.toList()).forEach(s -> fileList.getItems().add(new Label(s)));
            break;
        case "wordPicker":
            FileChooser fileChooser2 = new FileChooser();
            fileChooser2.setTitle("Open Resource File");
            File userDirectory2 = new File("." + File.separator + SOUTAI_FILE);
            fileChooser2.setInitialDirectory(userDirectory2);

            fileChooser2.getExtensionFilters().add(
                    new FileChooser.ExtensionFilter("All Files", "*.docx"));
            File selectedFile2 = fileChooser2.showOpenDialog(mainpage.getScene().getWindow());
            if (selectedFile2 != null) {
                initDocument = getLastParagraph(selectedFile2);
                geneLog.setText("wordファイルを選択しました");
            }
            break;
    }

}
 
開發者ID:Khromium,項目名稱:MakeSourceList4j,代碼行數:54,代碼來源:Controller.java


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