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


Java FileChooser.setInitialFileName方法代码示例

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


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

示例1: generateReport

import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
 * Generates a PDF report containing images of
 * the charts currently displayed to the user
 *
 * @param charts the charts that are to be exported as images to a PDF
 */
private void generateReport(List<Chart> charts) {

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Copy of Graphs");
    fileChooser.setInitialDirectory(
            new File(System.getProperty("user.home"))
    );
    fileChooser.setInitialFileName("Log Entry Graphs.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 {
            exportChartsIntoPDF(file, charts);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:kwilliams3,项目名称:Recordian,代码行数:30,代码来源:GraphsTabController.java

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

示例3: saveDungeon

import javafx.stage.FileChooser; //导入方法依赖的package包/类
private void saveDungeon(Stage stage)
{
	FileChooser chooser = new FileChooser();
	chooser.setInitialFileName("dungeon.json");
	File file = chooser.showSaveDialog(stage);

	if (file != null)
	{
		try
		{
			BufferedWriter writer = new BufferedWriter(new FileWriter(file));
			JSONObject data = Dungeon.writeToJSON(this.dungeon);
			JSON.write(writer, data);
			writer.flush();
			writer.close();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:23,代码来源:Ludwig.java

示例4: exportAction

import javafx.stage.FileChooser; //导入方法依赖的package包/类
@FXML private void exportAction() throws FileNotFoundException, UnsupportedEncodingException {
	FileChooser fileChooser = new FileChooser();
	String defaultFileName = ("".equals(textSchema.getText()) ? textDatabase.getText() : textSchema.getText());
	fileChooser.setInitialFileName(defaultFileName);
	fileChooser.getExtensionFilters().addAll(
			new FileChooser.ExtensionFilter("GraphML (yEd)", "*.graphml"),
			new FileChooser.ExtensionFilter("TGF (yEd)", "*.tgf"),
			new FileChooser.ExtensionFilter("DDL (Oracle Data Modeler)", "*.ddl"),
			new FileChooser.ExtensionFilter("SQL with alter queries", "*.sql"),
			new FileChooser.ExtensionFilter("CSV for PK", "*.csv"),
			new FileChooser.ExtensionFilter("CSV for FK", "*.csv"),
			new FileChooser.ExtensionFilter("Decision justification for PK", "*.csv"),
			new FileChooser.ExtensionFilter("Decision justification for FK", "*.csv"));
	File file = fileChooser.showSaveDialog(buttonRun.getScene().getWindow());

	if (file != null) {
		linkifier.export(file, fileChooser.getSelectedExtensionFilter().getDescription());
	}
}
 
开发者ID:janmotl,项目名称:linkifier,代码行数:20,代码来源:Events.java

示例5: exportPackagesButtonPressed

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public void exportPackagesButtonPressed(ActionEvent evt) throws FileNotFoundException, IOException {
    FileChooser saveChooser = new FileChooser();
    saveChooser.setTitle("Export (Save) data");
    saveChooser.setInitialFileName("package_list.xlsx");
    File saveFile = saveChooser.showSaveDialog(null);
    if (saveFile != null) {
        FileOutputStream out = new FileOutputStream(saveFile);
        String[] headers = new String[]{
            "Group", "Package Name", "Package File", "Size", "Version",
            "Created", "Created By",
            "Last Modified", "Modified By",
            "Last Unpacked", "Unpacked By"
        };
        ReportUtil.exportSpreadsheet(out, packageList, headers,
                PackageType::getGroup, PackageType::getName,
                PackageType::getDownloadName, PackageType::getSize,
                PackageOps::getInformativeVersion,
                PackageType::getCreated, PackageType::getCreatedBy,
                PackageType::getLastModified, PackageType::getLastModifiedBy,
                PackageType::getLastUnpacked, PackageType::getLastUnpackedBy
        );
        out.close();
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:aem-epic-tool,代码行数:25,代码来源:PackageListController.java

示例6: saveAs

import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
 * Choose a new file and save the dashboard to that file.
 */
@FXML
private void saveAs() throws IOException {
  FileChooser chooser = new FileChooser();
  chooser.getExtensionFilters().setAll(
      new FileChooser.ExtensionFilter("Shuffleboard Save File (.json)", "*.json"));
  if (currentFile == null) {
    chooser.setInitialDirectory(Storage.getStorageDir());
    chooser.setInitialFileName("shuffleboard.json");
  } else {
    chooser.setInitialDirectory(currentFile.getAbsoluteFile().getParentFile());
    chooser.setInitialFileName(currentFile.getName());
  }

  File selected = chooser.showSaveDialog(root.getScene().getWindow());

  saveFile(selected);
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:21,代码来源:MainWindowController.java

示例7: configureFileChooser

import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
 * Configure FileChooser window for saving/opening GameList from file.
 *
 * @param fileChooser
 *            FileChooser you want modified.
 */
private static void configureFileChooser(FileChooser fileChooser) {
    // set initial directory
    String appPath = GameShelf.class.getProtectionDomain().getCodeSource().getLocation().getPath();
    File userDataDirectory = new File(appPath + userDataDirName);
    File userDirectory = new File(System.getProperty("user.dir"));

    if (userDataDirectory.canRead()) {
        fileChooser.setInitialDirectory(userDataDirectory);
    } else if (userDirectory.canRead()) {
        fileChooser.setInitialDirectory(userDirectory);
    } else {
        fileChooser.setInitialDirectory(new File("C:/"));
    }

    // set selectable file types
    FileChooser.ExtensionFilter filterCSV = new FileChooser.ExtensionFilter("CSV", "*.csv");
    fileChooser.getExtensionFilters().clear();
    fileChooser.getExtensionFilters().add(filterCSV);

    // set default file name
    if (fileChooser.getInitialFileName() == null) {
        fileChooser.setInitialFileName("game_list");
    }
}
 
开发者ID:Stevoisiak,项目名称:Virtual-Game-Shelf,代码行数:31,代码来源:MainMenuBar.java

示例8: saveProjectFile

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public static File saveProjectFile(SquidProject squidProject, Window ownerWindow)
        throws IOException {

    File retVal = null;

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Project '.squid' file");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Squid Project files", "*.squid"));
    File initDirectory = new File(squidPersistentState.getMRUProjectFolderPath());
    fileChooser.setInitialDirectory(initDirectory.exists() ? initDirectory : null);
    fileChooser.setInitialFileName(squidProject.getProjectName().toUpperCase(Locale.US) + ".squid");

    File projectFileNew = fileChooser.showSaveDialog(ownerWindow);

    if (projectFileNew != null) {
        retVal = projectFileNew;
        ProjectFileUtilities.serializeSquidProject(squidProject, projectFileNew.getCanonicalPath());
    }

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

示例9: savePrawnFile

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

    File retVal = null;
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Prawn XML file");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Prawn XML files", "*.xml"));
    fileChooser.setInitialDirectory(squidProject.getPrawnFileHandler().currentPrawnFileLocationFolder());
    fileChooser.setInitialFileName(squidProject.getPrawnXMLFileName().toUpperCase(Locale.US).replace(".XML", "-REV.xml"));

    File prawnXMLFileNew = fileChooser.showSaveDialog(ownerWindow);

    if (prawnXMLFileNew != null) {
        squidProject.savePrawnFile(prawnXMLFileNew);
        retVal = prawnXMLFileNew;
    }

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

示例10: saveExpressionFileXML

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public static File saveExpressionFileXML(Expression expression, Window ownerWindow)
        throws IOException {

    File retVal = null;

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Expression '.xml' file");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Expression '.xml' files", "*.xml"));
    File mruFolder = new File(squidPersistentState.getMRUExpressionFolderPath());
    fileChooser.setInitialDirectory(mruFolder.isDirectory() ? mruFolder : null);
    fileChooser.setInitialFileName(expression.getName() + ".xml");

    File expressionFileXML = fileChooser.showSaveDialog(ownerWindow);

    if (expressionFileXML != null) {
        retVal = expressionFileXML;
        squidPersistentState.setMRUExpressionFolderPath(expressionFileXML.getParent());
        ((XMLSerializerInterface) expression)
                .serializeXMLObject(expressionFileXML.getAbsolutePath());
    }

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

示例11: generateFileAction

import javafx.stage.FileChooser; //导入方法依赖的package包/类
@FXML
public void generateFileAction(ActionEvent actionEvent) {
    FileChooser saveChooser = new FileChooser();
    Window stage = ((Node) actionEvent.getSource()).getScene().getWindow();
    saveChooser.setTitle("Zapisz plik");
    saveChooser.setInitialDirectory(new File(System.getProperty("user.home")));
    saveChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("PDF file", "*.pdf"));
    saveChooser.setInitialFileName("faktura.pdf");
    File file = saveChooser.showSaveDialog(stage);
    if (file != null) {
        try {
            updateData();
            model.setInvoiceData(invoiceData);
            model.setReceiverData(receiverData);
            model.setSenderData(senderData);
            model.generatePDF(file);
        } catch (IOException | DocumentException e) {
            Dialog dialog = new Dialog<>();
            dialog.getDialogPane().getButtonTypes().add(new ButtonType("Ok", ButtonBar.ButtonData.OK_DONE));
            dialog.setContentText("Wystąpił błąd podczas próby zapisu");
            dialog.showAndWait();
        }
    }
}
 
开发者ID:Garret29,项目名称:PDF_Invoice_generator,代码行数:25,代码来源:GeneratorController.java

示例12: saveSenderData

import javafx.stage.FileChooser; //导入方法依赖的package包/类
public void saveSenderData(ActionEvent actionEvent) {
    FileChooser saveChooser = new FileChooser();
    Window stage = senderMenuButton.getScene().getWindow();
    saveChooser.setTitle("Zapisz dane wystawcy");
    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(senderData.toString());
            fileWriter.flush();
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

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

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

示例14: loadDungeon

import javafx.stage.FileChooser; //导入方法依赖的package包/类
private void loadDungeon(Stage stage)
{
	FileChooser chooser = new FileChooser();
	chooser.setInitialFileName("dungeon.json");
	File file = chooser.showOpenDialog(stage);

	if (file != null)
	{
		try
		{
			JSONObject data;
			BufferedReader reader = new BufferedReader(new FileReader(file));
			JSONFormatParser parser = new JSONFormatParser(256);
			data = (JSONObject) parser.parse(reader);
			reader.close();
			this.dungeon = Dungeon.loadFromJSON(data);
			this.dungeonHandler = new DungeonHandler(this.dungeon);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:25,代码来源:Ludwig.java

示例15: exportTypeSummaries

import javafx.stage.FileChooser; //导入方法依赖的package包/类
@FXML
void exportTypeSummaries(ActionEvent event) throws IOException {
    FileChooser saveChooser = new FileChooser();
    saveChooser.setTitle("Export (Save) data");
    saveChooser.setInitialFileName(pkg.getName() + "_type_summary.xlsx");
    File saveFile = saveChooser.showSaveDialog(null);
    if (saveFile != null) {
        FileOutputStream out = new FileOutputStream(saveFile);
        String[] headers = new String[]{
            "Type", "Count"
        };
        ReportUtil.exportSpreadsheet(out, pkgContents.getFilesByType().entrySet(), headers,
                Map.Entry::getKey,
                e->e.getValue().size()
        );
        out.close();
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:aem-epic-tool,代码行数:19,代码来源:PackageInfoController.java


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