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


Java FileChooser.showSaveDialog方法代码示例

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


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

示例1: save

import javafx.stage.FileChooser; //导入方法依赖的package包/类
private void save(ActionEvent event) {
	FileChooser fileChooser = new FileChooser();
	fileChooser.setTitle("Save Game As...");
	fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("SGF", "*.sgf"));
	File file = fileChooser.showSaveDialog(null);

	if ( file != null ) {
		try {
			Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));

			SGFWriter sgf = game.getSGFWriter();

			writer.write(sgf.getSGFString());
			writer.close();
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:GoSuji,项目名称:Suji,代码行数:21,代码来源:GameMenuController.java

示例2: handleExportToJPEG

import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
 * A handler for the export to JPEG option in the context menu.
 */
private void handleExportToJPEG() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Export to JPEG");
    FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("JPEG", "jpg");
    chooser.getExtensionFilters().add(filter);
    File file = chooser.showSaveDialog(getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsJPEG(this.canvas.getChart(), (int) getWidth(),
                    (int) getHeight(), file);
        } catch (IOException ex) {
            // FIXME: show a dialog with the error
            throw new RuntimeException(ex);
        }
    }        
}
 
开发者ID:jfree,项目名称:jfreechart-fx,代码行数:20,代码来源:ChartViewer.java

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

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

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

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

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

示例10: handleFileSaveAction

import javafx.stage.FileChooser; //导入方法依赖的package包/类
@FXML
private void handleFileSaveAction(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    File file = fileChooser.showSaveDialog(null);
    
    if (file != null) {
        try {
            WritableImage writableImage = new WritableImage((int) drawingCanvas.getWidth(), (int) drawingCanvas.getHeight());
            drawingCanvas.snapshot(null, writableImage);
            RenderedImage renderedImage = SwingFXUtils.fromFXImage(writableImage, null);            
            ImageIO.write(renderedImage, "png", file);
        } catch (IOException ex) {
            Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:17,代码来源:FXMLDocumentController.java

示例11: exportRootSummaries

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

示例12: handleExportCat

import javafx.stage.FileChooser; //导入方法依赖的package包/类
@Override
public void handleExportCat(ActionEvent event) {
    if (!EntityManager.getInstance().isCatalogueLoaded()) {
        return;
    }
    FileChooser fc = new FileChooser();
    fc.setTitle("Export Catalogue");
    if (EntityManager.getInstance().hasLastExportLocation()) {
        fc.setInitialDirectory(EntityManager.getInstance().getLastExportLocation());
    }
    File f = fc.showSaveDialog(mainScene.getWindow());
    if (f != null) {
        mainScene.indicateWaiting(true);
        EntityManager.getInstance().exportCatalogue(f);
        mainScene.indicateWaiting(false);
    }
}
 
开发者ID:dbisUnibas,项目名称:ReqMan,代码行数:18,代码来源:MainHandler.java

示例13: btnSaveAction

import javafx.stage.FileChooser; //导入方法依赖的package包/类
@FXML
private void btnSaveAction()
{
	FileChooser fileChooser = new FileChooser();
	File file = fileChooser.showSaveDialog(btnSave.getScene().getWindow());
	
	if(file == null)
		return;
	
	try
	{
		FileWriter stream = new FileWriter(file);
		
		try
		{
			file.createNewFile();
			stream.write(txtArea.getText());
		}
		finally
		{
			stream.close();
		}
	}
	catch (IOException e)
	{
		e.printStackTrace();
	}
}
 
开发者ID:tengai650,项目名称:SnapDup,代码行数:29,代码来源:GenerateScriptDialog.java

示例14: onButtonSaveClick

import javafx.stage.FileChooser; //导入方法依赖的package包/类
/**
 * 保存当前画板内容到png
 *
 * @param event
 */
public void onButtonSaveClick(ActionEvent event) {
    mainPane.chooseNothing();
    button_save.setDisable(true);
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialFileName("picture" + System.currentTimeMillis());
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("PNG (*.png)", "*.png"));
    File file = fileChooser.showSaveDialog(this.stage);
    button_save.setDisable(false);

    mainPane.setClip(new Rectangle(canvas.getWidth(), canvas.getHeight()));
    snapshot(mainPane, file);
}
 
开发者ID:xfangfang,项目名称:PhotoScript,代码行数:18,代码来源:Controller.java

示例15: saveSessionAs

import javafx.stage.FileChooser; //导入方法依赖的package包/类
private void saveSessionAs(ActionEvent actionEvent) {
    FileChooser fileChooser = FileChooserFactory
            .createSaveFileChooser(SESSION,
                    rootModel.get().getWorkingdir());
    File chosenFile = fileChooser
            .showSaveDialog(view.getScene().getWindow());
    if (chosenFile != null) {
        handleSaveAll(chosenFile);
        setWorkingDir(chosenFile);
    }
}
 
开发者ID:VerifAPS,项目名称:stvs,代码行数:12,代码来源:StvsMenuBarController.java


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