本文整理汇总了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();
}
}
}
示例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
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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");
}
}
}
示例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());
}
示例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));
}
}
}
示例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();
}
}
}
示例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")
);
}
示例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;
}
示例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);
}
}
示例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());
}
}
示例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;
}