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