Java Code Examples for javafx.stage.FileChooser#setTitle()
The following examples show how to use
javafx.stage.FileChooser#setTitle() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditorMainWindow.java From metastone with GNU General Public License v2.0 | 6 votes |
private void save() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Save card"); fileChooser.setInitialDirectory(new File("./cards/")); fileChooser.setInitialFileName(card.id + ".json"); File file = fileChooser.showSaveDialog(getScene().getWindow()); if (file == null) { return; } System.out.println("Saving to: " + file.getName()); GsonBuilder builder = new GsonBuilder().setPrettyPrinting(); builder.disableHtmlEscaping(); builder.registerTypeAdapter(SpellDesc.class, new SpellDescSerializer()); Gson gson = builder.create(); String json = gson.toJson(card); try { // FileUtils.writeStringToFile(file, json); Path path = Paths.get(file.getPath()); Files.write(path, json.getBytes()); Desktop.getDesktop().open(file); } catch (IOException e) { e.printStackTrace(); } }
Example 2
Source File: PCGenFrame.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
void showOpenPartyChooser() { PropertyContext context = PCGenSettings.getInstance(); FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open PCGen Party File"); fileChooser.setInitialDirectory(new File(context.getProperty(PCGenSettings.PCP_SAVE_PATH))); FileChooser.ExtensionFilter extensionFilter = new FileChooser.ExtensionFilter( "party files only", "*.pcp" ); fileChooser.getExtensionFilters().add(extensionFilter); fileChooser.setSelectedExtensionFilter(extensionFilter); File file = GuiUtility.runOnJavaFXThreadNow(() -> fileChooser.showOpenDialog(null)); if (file != null) { loadPartyFromFile(file); } }
Example 3
Source File: FilesController.java From AudioBookConverter with GNU General Public License v2.0 | 6 votes |
private static String selectOutputFile(AudioBookInfo audioBookInfo) { JfxEnv env = ConverterApplication.getEnv(); final FileChooser fileChooser = new FileChooser(); String outputFolder = AppProperties.getProperty("output.folder"); fileChooser.setInitialDirectory(Utils.getInitialDirecotory(outputFolder)); fileChooser.setInitialFileName(Utils.getOuputFilenameSuggestion(audioBookInfo)); fileChooser.setTitle("Save AudioBook"); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter(M4B, "*." + M4B), new FileChooser.ExtensionFilter(M4A, "*." + M4A), new FileChooser.ExtensionFilter(MP3, "*." + MP3), new FileChooser.ExtensionFilter(OGG, "*." + OGG) ); File file = fileChooser.showSaveDialog(env.getWindow()); if (file == null) return null; File parentFolder = file.getParentFile(); AppProperties.setProperty("output.folder", parentFolder.getAbsolutePath()); return file.getPath(); }
Example 4
Source File: ImportWizardView1Controller.java From pikatimer with GNU General Public License v3.0 | 6 votes |
@FXML protected void chooseFile(ActionEvent fxevent){ final FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open CSV File"); if (model.getFileName().equals("")) { fileChooser.setInitialDirectory(PikaPreferences.getInstance().getCWD()); } else { fileChooser.setInitialFileName(model.getFileName()); } fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("CSV/TXT Files", "*.csv", "*.txt"), new FileChooser.ExtensionFilter("All files", "*") ); File file = fileChooser.showOpenDialog(fileChooserButton.getScene().getWindow()); if (file != null && file.exists() && file.isFile() && file.canRead()) { // model.setFileName(file.getAbsolutePath()); fileTextField.setText(file.getAbsolutePath()); //model.nextButtonDisabledProperty().set(false); } }
Example 5
Source File: Controller.java From J-Kinopoisk2IMDB with Apache License 2.0 | 6 votes |
@FXML protected void handleFileChoseAction(ActionEvent event) { FileChooser choser = new FileChooser(); choser.setTitle("Выберите список кинопоиска:"); choser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("XLS", "*.xls"), new FileChooser.ExtensionFilter("Все файлы", "*.*") ); File file = choser.showOpenDialog(stage); if (file != null) { selectFileBtn.setText("Выбрать другой файл..."); selectedFile.setText(file.getPath()); clientExecutor.setFilePath(file.toPath()); runBtn.setDisable(false); } }
Example 6
Source File: IdeController.java From jace with GNU General Public License v2.0 | 5 votes |
private File chooseFileToSave(DocumentType type) { FileChooser chooser = new FileChooser(); chooser.setTitle("Save " + type.name() + " document"); chooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter(type.name(), type.extensions), new FileChooser.ExtensionFilter("All Files", "*.*") ); return chooser.showSaveDialog(JaceApplication.getApplication().primaryStage); }
Example 7
Source File: Exporter.java From latexdraw with GNU General Public License v3.0 | 5 votes |
@Inject public Exporter(final PreferencesService prefs, final PSTCodeGenerator pstGen, final StatusBarController statusBar, final TemplateManager templateManager, final JfxUI app, final Canvas canvas, final SVGDocumentGenerator svgGen, final LaTeXDataService latexData) { super(); this.prefs = Objects.requireNonNull(prefs); this.pstGen = Objects.requireNonNull(pstGen); this.latexData = Objects.requireNonNull(latexData); this.statusBar = Objects.requireNonNull(statusBar); this.templateManager = Objects.requireNonNull(templateManager); this.app = Objects.requireNonNull(app); this.canvas = Objects.requireNonNull(canvas); this.svgGen = Objects.requireNonNull(svgGen); fileChooserExport = new FileChooser(); fileChooserExport.setTitle(prefs.getBundle().getString("drawingExported")); }
Example 8
Source File: MainController.java From qiniu with MIT License | 5 votes |
/** * 显示选择文件的弹窗 */ public void showOpenFileDialog() { FileChooser chooser = new FileChooser(); chooser.setTitle(QiniuValueConsts.FILE_CHOOSER_TITLE); chooser.setInitialDirectory(new File(Utils.getCurrentWorkDir())); appendFile(chooser.showOpenMultipleDialog(QiniuApplication.getStage())); }
Example 9
Source File: ChartViewer.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A handler for the export to PDF option in the context menu. */ private void handleExportToPDF() { FileChooser fileChooser = new FileChooser(); fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter( "Portable Document Format (PDF)", "pdf")); fileChooser.setTitle("Export to PDF"); File file = fileChooser.showSaveDialog(this.getScene().getWindow()); if (file != null) { ExportUtils.writeAsPDF(this.chart, (int) getWidth(), (int) getHeight(), file); } }
Example 10
Source File: MsSpectrumPlotWindowController.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
public void handleExportTXT(Event event) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Export to TXT"); fileChooser.getExtensionFilters().add(new ExtensionFilter("TXT", "*.txt")); // Remember last directory if (lastSaveDirectory != null && lastSaveDirectory.isDirectory()) fileChooser.setInitialDirectory(lastSaveDirectory); // Show the file chooser File file = fileChooser.showSaveDialog(chartNode.getScene().getWindow()); // If nothing was chosen, quit if (file == null) return; // Save the last open directory lastSaveDirectory = file.getParentFile(); final List<MsSpectrum> spectra = new ArrayList<>(); for (MsSpectrumDataSet dataset : datasets) { spectra.add(dataset.getSpectrum()); } // Do the export in a new thread final File finalFile = file; new Thread(() -> { try { TxtExportAlgorithm.exportSpectra(finalFile, spectra); } catch (Exception e) { MZmineGUI.displayMessage("Unable to export: " + e.getMessage()); e.printStackTrace(); } }).start(); }
Example 11
Source File: ChartViewer.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * A handler for the export to PDF option in the context menu. */ private void handleExportToPDF() { FileChooser fileChooser = new FileChooser(); fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter( "Portable Document Format (PDF)", "pdf")); fileChooser.setTitle("Export to PDF"); File file = fileChooser.showSaveDialog(this.getScene().getWindow()); if (file != null) { ExportUtils.writeAsPDF(this.chart, (int) getWidth(), (int) getHeight(), file); } }
Example 12
Source File: AppController.java From curly with Apache License 2.0 | 5 votes |
@FXML void saveActionSequence(ActionEvent event) { FileChooser openChooser = new FileChooser(); openChooser.setTitle(ApplicationState.getMessage("saveActionSequence")); File targetFile = openChooser.showSaveDialog(null); if (targetFile != null) { ActionUtils.saveToFile(targetFile, actionList.getItems()); } }
Example 13
Source File: OutputPanel.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
private void onOutputSheetSpellsDefaultButton(final ActionEvent actionEvent) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(LanguageBundle.getString("in_Prefs_outputSpellSheetDefault")); fileChooser.setInitialDirectory(new File(ConfigurationSettings.getOutputSheetsDir())); fileChooser.setInitialFileName(PCGenSettings.getSelectedSpellSheet()); File newTemplate = GuiUtility.runOnJavaFXThreadNow(() -> fileChooser.showOpenDialog(null)); if (newTemplate != null) { if (newTemplate.getName().startsWith("csheet")) { PCGenSettings.getInstance().setProperty( PCGenSettings.SELECTED_SPELL_SHEET_PATH, newTemplate.getAbsolutePath() ); } else { ShowMessageDelegate.showMessageDialog( LanguageBundle.getString("in_Prefs_outputSheetDefaultError"), //$NON-NLS-1$ Constants.APPLICATION_NAME, MessageType.ERROR ); } } outputSheetSpellsDefault.setText(PCGenSettings.getSelectedSpellSheet()); }
Example 14
Source File: BodyTabController.java From Everest with Apache License 2.0 | 5 votes |
@FXML private void browseFile() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Choose a binary file to add to the request"); Window dashboardWindow = filePathField.getScene().getWindow(); String filePath; try { filePath = fileChooser.showOpenDialog(dashboardWindow).getAbsolutePath(); } catch (NullPointerException NPE) { filePath = ""; } filePathField.setText(filePath); }
Example 15
Source File: SingleImageAnalyzerController.java From FakeImageDetection with GNU General Public License v3.0 | 5 votes |
@FXML private void loadImage(ActionEvent event) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select Image"); imgSrc = fileChooser.showOpenDialog(rootPane.getScene().getWindow()); if (imgSrc != null) { imgIndicator.setSelected(true); } }
Example 16
Source File: FileDialogueImpl.java From VocabHunter with Apache License 2.0 | 5 votes |
@Override public void showChooser() { FileChooser chooser = new FileChooser(); chooser.setTitle(i18nManager.text(type.getTitleKey())); chooser.getExtensionFilters().addAll(filters); File initialDirectory = pathGetter.apply(this.settingsManager).toFile(); chooser.setInitialDirectory(initialDirectory); selected = showChooser(chooser); }
Example 17
Source File: JStackFXController.java From jstackfx with Apache License 2.0 | 5 votes |
/** * Opens a file chooser and open the dump file in the UI. */ protected void chooseDumpToOpen() throws IOException, InstantiationException, IllegalAccessException { final FileChooser chooser = new FileChooser(); chooser.setTitle("Open dump file"); final File fileToOpen = chooser.showOpenDialog(null); if (fileToOpen != null) { this.loadDumpFile(fileToOpen); } }
Example 18
Source File: MainApp.java From Corendon-LostLuggage with MIT License | 5 votes |
public static File selectFileToSave(String defaultFileName) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Specify filename"); //todo: provide the file selection dialog to the user File file = fileChooser.showSaveDialog(mainStage); //File selected? return the file, else return null if (file != null) { return file; } else { return null; } }
Example 19
Source File: PCGenFrame.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
public void showOpenCharacterChooser() { GuiAssertions.assertIsNotJavaFXThread(); PropertyContext context = PCGenSettings.getInstance(); String path = lastCharacterPath; if (path == null) { path = context.getProperty(PCGenSettings.PCG_SAVE_PATH); } FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open PCGen Character"); fileChooser.setInitialDirectory(new File(path)); FileChooser.ExtensionFilter extensionFilter = new FileChooser.ExtensionFilter( "character files only", '*' + Constants.EXTENSION_CHARACTER_FILE ); fileChooser.getExtensionFilters().add(extensionFilter); fileChooser.setSelectedExtensionFilter(extensionFilter); File file = GuiUtility.runOnJavaFXThreadNow(() -> fileChooser.showOpenDialog(null)); if (file != null) { lastCharacterPath = file.getAbsoluteFile().getParent(); loadCharacterFromFile(file); } }
Example 20
Source File: DataInstaller.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void actionPerformed(ActionEvent actionEvent) { JButton source = (JButton) actionEvent.getSource(); if (source == null) { // Do nothing } else if (source.equals(closeButton)) { setVisible(false); dispose(); } else if (source.equals(selectButton)) { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(currFolder); fileChooser.setTitle(LanguageBundle.getString("in_diChooserTitle")); FileChooser.ExtensionFilter dataSetFilter = new FileChooser.ExtensionFilter( "Data Sets", "*.pcz", "*.zip" ); fileChooser.getExtensionFilters().add(dataSetFilter); fileChooser.setSelectedExtensionFilter(dataSetFilter); File dataset = GuiUtility.runOnJavaFXThreadNow(() -> fileChooser.showOpenDialog(null)); if (dataset == null) { return; } currFolder = dataset.getParentFile(); readDataSet(dataset); } else if (source.equals(installButton)) { if (installDataSource(currDataSet, getSelectedDestination())) { //PCGen_Frame1.getInst().getMainSource().refreshCampaigns(); //TODO: Refresh the data cleanly. // PersistenceManager.getInstance().refreshCampaigns(); // FacadeFactory.refresh(); ShowMessageDelegate.showMessageDialog( LanguageBundle.getFormattedString("in_diInstalled", campaign //$NON-NLS-1$ .getDisplayName()), TITLE, MessageType.INFORMATION); } } }