當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。