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


Java FileChooser.setInitialDirectory方法代码示例

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


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

示例1: generateReport

import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
 * Generates a PDF report for the
 * user to save wherever they choose
 */
private void generateReport() {

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Copy of Report");
    fileChooser.setInitialDirectory(
            new File(System.getProperty("user.home"))
    );
    fileChooser.setInitialFileName("Log Entries.pdf");
    FileChooser.ExtensionFilter pdfExtensionFilter =
            new FileChooser.ExtensionFilter(
                    "PDF - Portable Document Format (.pdf)", "*.pdf");
    fileChooser.getExtensionFilters().add(pdfExtensionFilter);
    fileChooser.setSelectedExtensionFilter(pdfExtensionFilter);
    File file = fileChooser.showSaveDialog(currentStage);

    if (file != null) {
        try {
            exportTableAsPDF(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:kwilliams3,项目名称:Recordian,代码行数:28,代码来源:EditLogEntriesTabController.java

示例2: fileOpen

import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
 * open the log File
 */
private void fileOpen() {
  FileChooser fileChooser = new FileChooser();
  if (Config.getInstance() != null)
    try {
      File logDirectory = new File(
          Preferences.getInstance().getLogDirectory());
      if (!logDirectory.exists())
        logDirectory.mkdirs();
      fileChooser.setInitialDirectory(logDirectory);
    } catch (Exception e1) {
      // Ignore
    }
  File file = fileChooser.showOpenDialog(stage);
  if (file != null) {
    initSimulation(file.getAbsolutePath());
  } // if
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:21,代码来源:JavaFXDisplay.java

示例3: selectProjectFile

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public static String selectProjectFile(Window ownerWindow)
        throws IOException {
    String retVal = "";

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select Project '.squid' file");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Squid Project files", "*.squid"));
    File initDirectory = new File(squidPersistentState.getMRUProjectFolderPath());
    fileChooser.setInitialDirectory(initDirectory.exists() ? initDirectory : null);

    File projectFileNew = fileChooser.showOpenDialog(ownerWindow);

    if (projectFileNew != null) {
        retVal = projectFileNew.getCanonicalPath();
    }

    return retVal;
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:19,代码来源:FileHandler.java

示例4: processAdd

import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
 * Process install a plugin.
 */
@FXThread
private void processAdd() {

    GAnalytics.sendPageView("PluginChooseDialog", null, "/dialog/PluginChooseDialog");
    GAnalytics.sendEvent(GAEvent.Category.DIALOG, GAEvent.Action.DIALOG_OPENED, "PluginChooseDialog");

    final FileChooser chooser = new FileChooser();
    chooser.setTitle(Messages.PLUGINS_DIALOG_FILE_CHOOSER_TITLE);
    chooser.setSelectedExtensionFilter(new ExtensionFilter(Messages.PLUGINS_DIALOG_FILE_CHOOSER_FILTER, "*.zip"));
    chooser.setInitialDirectory(new File(System.getProperty("user.home")));

    final File result = chooser.showOpenDialog(getDialog());

    if (result == null) {
        return;
    }

    PLUGIN_MANAGER.installPlugin(result.toPath());

    refreshPlugins();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:25,代码来源:PluginsDialog.java

示例5: selectPrawnFile

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public static File selectPrawnFile(Window ownerWindow)
        throws IOException, JAXBException, SAXException {
    File retVal = null;

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

    File prawnXMLFileNew = fileChooser.showOpenDialog(ownerWindow);

    if (prawnXMLFileNew != null) {
        if (prawnXMLFileNew.getName().toLowerCase(Locale.US).endsWith(".xml")) {
            retVal = prawnXMLFileNew;
        } else {
            throw new IOException("Filename does not end with '.xml'");
        }
    }

    return retVal;
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:23,代码来源:FileHandler.java

示例6: savePdfFile

import javafx.stage.FileChooser; //导入方法依赖的package包/类
protected  boolean savePdfFile(File contentFile, MarkdownParser markdownParser, String content, String actionText) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(contentFile.getParentFile());
    fileChooser.setInitialFileName(contentFile.getName().split("\\.")[0] + ".pdf");
    fileChooser.getExtensionFilters().add(FileExtensionFilters.PDF);
    File file = fileChooser.showSaveDialog(primaryStage);
    if(file != null){
        timer.start();
        PdfConverterExtension.exportToPdf(
                file.getAbsolutePath(),
                markdownParser.convertToHTML(Utils.wrapWithHtmlDocType(content)),
                "",
                markdownParser.getOptions()
        );
        toolbar.setActionText(actionText + " in " + timer.end() + "ms");
        return true;
    }
    return false;
}
 
开发者ID:jdesive,项目名称:textmd,代码行数:20,代码来源:SaveMachine.java

示例7: handleExportOverview

import javafx.stage.FileChooser; //导入方法依赖的package包/类
@Override
public void handleExportOverview(ActionEvent event) {
    LOGGER.traceEntry();
    if (mainScene.isEvaluatorActive()) {
        if (evaluatorHandler.isGroupLoaded()) {
            FileChooser fc = new FileChooser();
            fc.setTitle("Export Overview");
            if (EntityManager.getInstance().hasLastExportLocation()) {
                fc.setInitialDirectory(EntityManager.getInstance().getLastExportLocation());
            }
            File f = fc.showSaveDialog(mainScene.getWindow());
            if (f != null) {
                mainScene.indicateWaiting(true);
                EntityManager.getInstance().exportOverview(f);
                mainScene.indicateWaiting(false);
            }
        } else {
            Utils.showErrorDialog("Export Failed", "Cannot export an overview if no groups are loaded");
        }
    }
}
 
开发者ID:dbisUnibas,项目名称:ReqMan,代码行数:22,代码来源:MainHandler.java

示例8: showFileChooser

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public static File showFileChooser(Scene scene, FileChooser.ExtensionFilter filter) {
    String home = System.getProperty("user.home");
    File[] downloads = {
            new File(home + "/Downloads/"),
            new File(home + "/Загрузки/"),
            new File(home)
    };
    FileChooser fileChooser = new FileChooser();
    for (File download : downloads) {
        if (download.exists()) {
            fileChooser.setInitialDirectory(download);
            break;
        }
    }
    fileChooser.setSelectedExtensionFilter(filter);
    return fileChooser.showOpenDialog(scene.getWindow());
}
 
开发者ID:KursX,项目名称:Parallator,代码行数:18,代码来源:Helper.java

示例9: loadSenderData

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public void loadSenderData(ActionEvent actionEvent) {
    FileChooser chooser = new FileChooser();
    Window stage = senderMenuButton.getScene().getWindow();
    chooser.setTitle("Wybierz plik z danymi wystawcy");
    chooser.setInitialDirectory(new File(System.getProperty("user.home")));
    File file = chooser.showOpenDialog(stage);
    if (file != null) {
        String jsonData = null;
        try {
            InputStream inputStream = new FileInputStream(file);
            jsonData = org.apache.commons.io.IOUtils.toString(inputStream);

        } catch (IOException e) {
            e.printStackTrace();
        }
        if (jsonData != null) {
            fillSenderData(new JSONObject(jsonData));
        }
    }
}
 
开发者ID:Garret29,项目名称:PDF_Invoice_generator,代码行数:21,代码来源:GeneratorController.java

示例10: saveReceiverData

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public void saveReceiverData(ActionEvent actionEvent) {
    FileChooser saveChooser = new FileChooser();
    Window stage = receiverMenuButton.getScene().getWindow();
    saveChooser.setTitle("Zapisz dane odbiorcy");
    saveChooser.setInitialDirectory(new File(System.getProperty("user.home")));
    saveChooser.setInitialFileName("file.txt");
    File file = saveChooser.showSaveDialog(stage);

    if (file != null) {
        updateData();
        try {
            FileWriter fileWriter = new FileWriter(file);
            fileWriter.write(receiverData.toString());
            fileWriter.flush();
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
 
开发者ID:Garret29,项目名称:PDF_Invoice_generator,代码行数:23,代码来源:GeneratorController.java

示例11: configureFileChooser

import javafx.stage.FileChooser; //导入方法依赖的package包/类
private static void configureFileChooser(
        final FileChooser fileChooser) {
    fileChooser.setTitle("View Pictures");
    fileChooser.setInitialDirectory(
            new File(System.getProperty("user.home"))
    );
    fileChooser.getExtensionFilters().addAll(
            new FileChooser.ExtensionFilter("All Images", "*.*"),
            new FileChooser.ExtensionFilter("JPG", "*.jpg"),
            new FileChooser.ExtensionFilter("PNG", "*.png")
    );
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:13,代码来源:FileChooserSample.java

示例12: makeChooser

import javafx.stage.FileChooser; //导入方法依赖的package包/类
private FileChooser makeChooser (String extensionAccepted) {
    FileChooser result = new FileChooser();
    result.setTitle("Choose Game XML File");
    // pick a reasonable place to start searching for files
    result.setInitialDirectory(new File(System.getProperty("user.dir")));
    result.getExtensionFilters().setAll(new ExtensionFilter("XML Files", extensionAccepted));
    return result;
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:9,代码来源:FileLoader.java

示例13: onOpenClicked

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public void onOpenClicked()
{
    try
    {
        final FileChooser fileChooser = new FileChooser();

        fileChooser.setTitle("Open Cayenne Model");
        fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));

        fileChooser.getExtensionFilters().addAll
            (
                new FileChooser.ExtensionFilter("Cayenne Projects", "cayenne*.xml"),
                new FileChooser.ExtensionFilter("All Files", "*.*")
            );

        final File file = fileChooser.showOpenDialog(getStage());

        if (file != null)
        {
            CayenneModeler.openProject(file.getAbsolutePath());
            hide();
        }
        else
        {
            LOGGER.info("Open canceled");
        }
    }
    catch (final Exception exception)
    {
        // TODO Auto-generated catch block
        LOGGER.error("Could not load Cayenne model", exception);
    }
}
 
开发者ID:apache,项目名称:cayenne-modeler,代码行数:34,代码来源:SplashLayout.java

示例14: browseToSaveFile

import javafx.stage.FileChooser; //导入方法依赖的package包/类
@FXML
protected void browseToSaveFile() {
    FileChooser directoryChooser = new FileChooser();
    if (JGMRConfig.getInstance().getPath() != null) {
        directoryChooser.setInitialDirectory(new File(JGMRConfig.getInstance().getPath()));
    }
    Stage stage = new Stage();
    File fileResult = directoryChooser.showOpenDialog(stage);
    if (fileResult != null) {
        tbSaveFile.setText(fileResult.getAbsolutePath());
    }

}
 
开发者ID:eternia16,项目名称:javaGMR,代码行数:14,代码来源:UploadSaveFileDialogController.java

示例15: getFileChooser

import javafx.stage.FileChooser; //导入方法依赖的package包/类
private static FileChooser getFileChooser(String title, File initialDirectory, Window ownerWindow, ExtensionFilter filter) {
    FileChooser fileChooser = new FileChooser();
    if (filter != null) {
        fileChooser.getExtensionFilters().add(filter);
    }
    fileChooser.setTitle(title);
    fileChooser.setInitialDirectory(initialDirectory);
    return fileChooser;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:10,代码来源:FXUIUtils.java


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