Java Code Examples for javafx.stage.FileChooser#showOpenDialog()
The following examples show how to use
javafx.stage.FileChooser#showOpenDialog() .
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: PlayConfigurationView.java From beatoraja with GNU General Public License v3.0 | 6 votes |
@FXML public void importScoreDataFromLR2() { FileChooser chooser = new FileChooser(); chooser.getExtensionFilters().setAll(new ExtensionFilter("Lunatic Rave 2 Score Database File", "*.db")); chooser.setTitle("LRのスコアデータベースを選択してください"); File dir = chooser.showOpenDialog(null); if (dir == null) { return; } try { Class.forName("org.sqlite.JDBC"); SongDatabaseAccessor songdb = MainLoader.getScoreDatabaseAccessor(); String player = players.getValue(); ScoreDatabaseAccessor scoredb = new ScoreDatabaseAccessor(config.getPlayerpath() + File.separatorChar + player + File.separatorChar + "score.db"); scoredb.createTable(); ScoreDataImporter scoreimporter = new ScoreDataImporter(scoredb); scoreimporter.importFromLR2ScoreDatabase(dir.getPath(), songdb); } catch (ClassNotFoundException e1) { } }
Example 2
Source File: ImagesBlendController.java From MyBox with Apache License 2.0 | 6 votes |
@FXML public void selectForegroundImage() { try { final FileChooser fileChooser = new FileChooser(); File path = AppVariables.getUserConfigPath(sourcePathKey); if (path.exists()) { fileChooser.setInitialDirectory(path); } fileChooser.getExtensionFilters().addAll(sourceExtensionFilter); final File file = fileChooser.showOpenDialog(getMyStage()); if (file == null) { return; } selectForegroundImage(file); } catch (Exception e) { logger.error(e.toString()); } }
Example 3
Source File: GameElimniationController.java From MyBox with Apache License 2.0 | 6 votes |
@FXML public void selectSoundFile() { try { if (!checkBeforeNextAction()) { return; } final FileChooser fileChooser = new FileChooser(); File path = AppVariables.getUserConfigPath("MusicPath"); if (path.exists()) { fileChooser.setInitialDirectory(path); } fileChooser.getExtensionFilters().addAll(CommonFxValues.Mp3WavExtensionFilter); File file = fileChooser.showOpenDialog(getMyStage()); if (file == null || !file.exists()) { return; } selectSoundFile(file); } catch (Exception e) { // logger.error(e.toString()); } }
Example 4
Source File: LoadPane.java From pattypan with MIT License | 6 votes |
/** * Shows spreadsheet shooser dialog. */ private void selectSpreadSheetFile() { FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter(Util.text("validate-file-type"), "*.xls"); FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(Util.text("validate-file-select")); fileChooser.getExtensionFilters().add(extFilter); File initialDir = !Settings.getSetting("path").isEmpty() ? new File(Settings.getSetting("path")) : null; fileChooser.setInitialDirectory(initialDir); File spreadsheet; try { spreadsheet = fileChooser.showOpenDialog(stage); } catch (IllegalArgumentException ex) { fileChooser.setInitialDirectory(null); spreadsheet = fileChooser.showOpenDialog(stage); } if (spreadsheet != null) { loadSpreadsheet(spreadsheet); } }
Example 5
Source File: HDF5.java From paintera with GNU General Public License v2.0 | 6 votes |
private void updateFromFileChooser(final File initialDirectory, final Window owner) { final FileChooser fileChooser = new FileChooser(); fileChooser.getExtensionFilters().setAll(new FileChooser.ExtensionFilter("h5", H5_EXTENSIONS)); fileChooser.setInitialDirectory(Optional .ofNullable(container.get()) .map(File::new) .map(f -> f.isFile() ? f.getParentFile() : f) .filter(File::exists) .orElse(new File(USER_HOME))); final File updatedRoot = fileChooser.showOpenDialog(owner); LOG.debug("Updating root to {}", updatedRoot); if (updatedRoot != null && updatedRoot.exists() && updatedRoot.isFile()) container.set(updatedRoot.getAbsolutePath()); }
Example 6
Source File: EmulatorUILogic.java From jace with GNU General Public License v2.0 | 6 votes |
@InvokableAction( name = "BRUN file", category = "file", description = "Loads a binary file in memory and executes it. File should end with #06xxxx, where xxxx is the start address in hex", alternatives = "Execute program;Load binary;Load program;Load rom;Play single-load game", defaultKeyMapping = "ctrl+shift+b") public static void runFile() { Emulator.computer.pause(); FileChooser select = new FileChooser(); File binary = select.showOpenDialog(JaceApplication.getApplication().primaryStage); if (binary == null) { Emulator.computer.resume(); return; } runFileNamed(binary); }
Example 7
Source File: Controller.java From xdat_editor with MIT License | 6 votes |
@FXML private void open() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open script"); if (initialDirectory != null) fileChooser.setInitialDirectory(initialDirectory); scriptFile = fileChooser.showOpenDialog(editor.getStage()); if (scriptFile == null) return; initialDirectory = scriptFile.getParentFile(); try { scriptText.setText(getText(scriptFile)); output.setText(""); } catch (IOException e) { String msg = "Read error"; log.log(Level.WARNING, msg, e); Dialogs.showException(Alert.AlertType.WARNING, msg, e.getMessage(), e); } }
Example 8
Source File: FilesCompareController.java From MyBox with Apache License 2.0 | 6 votes |
@FXML public void selectFile2() { try { final FileChooser fileChooser = new FileChooser(); File path = AppVariables.getUserConfigPath(sourcePathKey); if (path.exists()) { fileChooser.setInitialDirectory(path); } fileChooser.getExtensionFilters().addAll(sourceExtensionFilter); File file = fileChooser.showOpenDialog(myStage); if (file == null || !file.exists()) { return; } file2Input.setText(file.getAbsolutePath()); } catch (Exception e) { // logger.error(e.toString()); } }
Example 9
Source File: ImageManufacturePaneController.java From MyBox with Apache License 2.0 | 6 votes |
@FXML public void selectOutlineFile() { try { final FileChooser fileChooser = new FileChooser(); File path = AppVariables.getUserConfigPath(sourcePathKey); if (path.exists()) { fileChooser.setInitialDirectory(path); } fileChooser.getExtensionFilters().addAll(CommonFxValues.AlphaImageExtensionFilter); final File file = fileChooser.showOpenDialog(getMyStage()); if (file == null) { return; } recordFileOpened(file); loadOutlineSource(file); } catch (Exception e) { logger.error(e.toString()); } }
Example 10
Source File: MainController.java From KorgPackage with GNU General Public License v3.0 | 6 votes |
public void openPkgAction() { FileChooser fileChooser = new FileChooser(); fileChooser.setInitialDirectory(lastFileChooserPath); fileChooser.setTitle("Open PKG/UPD File"); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("PKG/UPD file", "*.pkg", "*.upd"), new FileChooser.ExtensionFilter("All files", "*.*") ); File file = fileChooser.showOpenDialog(stage); if (file != null) { lastFileChooserPath = file.getParentFile(); List<Chunk> chunks = new PackageReader(file).load(); chunksListView.setItems(FXCollections.observableArrayList(chunks)); statusLabel.setText("Finished reading package"); } }
Example 11
Source File: ProjectParametersImporter.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
private File chooseFile() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Please select a file containing project parameter values for files."); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("All Files","*.*"), new FileChooser.ExtensionFilter("text","*.txt"), new FileChooser.ExtensionFilter("csv","*.csv") ); File currentFile = currentProject.getProjectFile(); if (currentFile != null) { File currentDir = currentFile.getParentFile(); if ((currentDir != null) && (currentDir.exists())) fileChooser.setInitialDirectory(currentDir); } return fileChooser.showOpenDialog(currentStage.getScene().getWindow()); }
Example 12
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 13
Source File: TestCollectionController.java From pmd-designer with BSD 2-Clause "Simplified" License | 6 votes |
private void importTestsFromFile() { FileChooser chooser = new FileChooser(); File origin = getTestCollection().getOrigin(); chooser.setInitialFileName(origin == null ? null : origin.getAbsolutePath()); chooser.setTitle("Load source from file"); File file = chooser.showOpenDialog(getMainStage()); if (file == null) { SimplePopups.showActionFeedback(addTestMenuButton, AlertType.INFORMATION, "No file chosen"); return; } try { TestCollection coll = TestXmlParser.parseXmlTests(file.toPath(), builder); getTestCollection().addAll(coll); getTestCollection().setOrigin(file); SimplePopups.showActionFeedback(addTestMenuButton, AlertType.CONFIRMATION, "Imported " + coll.getStash().size() + " test cases"); } catch (Exception e) { SimplePopups.showActionFeedback(addTestMenuButton, AlertType.ERROR, "Error while importing, see event log"); logUserException(e, Category.TEST_LOADING_EXCEPTION); } }
Example 14
Source File: MainFm.java From tools-ocr with GNU Lesser General Public License v3.0 | 6 votes |
private static void recImage() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Please Select Image File"); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Image Files", "*.png", "*.jpg")); File selectedFile = fileChooser.showOpenDialog(stage); if (selectedFile == null || !selectedFile.isFile()) { return; } stageInfo = new StageInfo(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight(), stage.isFullScreen()); MainFm.stage.close(); try { BufferedImage image = ImageIO.read(selectedFile); doOcr(image); } catch (IOException e) { StaticLog.error(e); } }
Example 15
Source File: SampleController.java From neembuu-uploader with GNU General Public License v3.0 | 5 votes |
@FXML void browse(ActionEvent event) { final FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Choose file to upload"); final Button openButton = new Button("Open a Picture..."); /*openButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(final ActionEvent e) { File file = fileChooser.showOpenDialog(stage); if (file != null) { f = file; } } });*/ f = fileChooser.showOpenDialog(stage); if(f==null)return; filepath.setText(f.getAbsolutePath()); browseButton.setVisible(false); /*final GridPane inputGridPane = new GridPane(); GridPane.setConstraints(openButton, 0, 0); inputGridPane.setHgap(6); inputGridPane.setVgap(6); inputGridPane.getChildren().addAll(openButton); final Pane rootGroup = new VBox(12); rootGroup.getChildren().addAll(inputGridPane); rootGroup.setPadding(new Insets(12, 12, 12, 12));*/ }
Example 16
Source File: DataImporterController.java From curly with Apache License 2.0 | 5 votes |
@FXML void chooseFile(ActionEvent event) { FileChooser openFileDialog = new FileChooser(); openFileDialog.setTitle(ApplicationState.getMessage(CHOOSE_TEXT_OR_EXCEL)); File selected = openFileDialog.showOpenDialog(null); if (selected != null && selected.exists() && selected.isFile()) { openFile(selected); } }
Example 17
Source File: ArenaBackgroundsSlide.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
public void selectedLocalImage() { final FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select Arena Background"); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("Portable Network Graphic (*.png)", "*.png"), new FileChooser.ExtensionFilter("Graphics Interchange Format (*.gif)", "*.gif")); final File backgroundFile = fileChooser.showOpenDialog(shootOffStage); if (backgroundFile != null) { final LocatedImage img = new LocatedImage(backgroundFile.toURI().toString()); arenaPane.setArenaBackground(img); } }
Example 18
Source File: ExtensionsController.java From G-Earth with MIT License | 5 votes |
public void installBtnClicked(ActionEvent actionEvent) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Install extension"); fileChooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("G-Earth extensions", ExecutionInfo.ALLOWEDEXTENSIONTYPES)); File selectedFile = fileChooser.showOpenDialog(parentController.getStage()); if (selectedFile != null) { extensionRunner.installAndRunExtension(selectedFile.getPath(), networkExtensionsProducer.getPort()); } }
Example 19
Source File: GUIUtil.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
public static void importAccounts(User user, String fileName, Preferences preferences, Stage stage, PersistenceProtoResolver persistenceProtoResolver, CorruptedDatabaseFilesHandler corruptedDatabaseFilesHandler) { FileChooser fileChooser = new FileChooser(); File initDir = new File(preferences.getDirectoryChooserPath()); if (initDir.isDirectory()) { fileChooser.setInitialDirectory(initDir); } fileChooser.setTitle(Res.get("guiUtil.accountExport.selectPath", fileName)); File file = fileChooser.showOpenDialog(stage.getOwner()); if (file != null) { String path = file.getAbsolutePath(); if (Paths.get(path).getFileName().toString().equals(fileName)) { String directory = Paths.get(path).getParent().toString(); preferences.setDirectoryChooserPath(directory); Storage<PaymentAccountList> paymentAccountsStorage = new Storage<>(new File(directory), persistenceProtoResolver, corruptedDatabaseFilesHandler); PaymentAccountList persisted = paymentAccountsStorage.initAndGetPersistedWithFileName(fileName, 100); if (persisted != null) { final StringBuilder msg = new StringBuilder(); final HashSet<PaymentAccount> paymentAccounts = new HashSet<>(); persisted.getList().forEach(paymentAccount -> { final String id = paymentAccount.getId(); if (user.getPaymentAccount(id) == null) { paymentAccounts.add(paymentAccount); msg.append(Res.get("guiUtil.accountExport.tradingAccount", id)); } else { msg.append(Res.get("guiUtil.accountImport.noImport", id)); } }); user.addImportedPaymentAccounts(paymentAccounts); new Popup().feedback(Res.get("guiUtil.accountImport.imported", path, msg)).show(); } else { new Popup().warning(Res.get("guiUtil.accountImport.noAccountsFound", path, fileName)).show(); } } else { log.error("The selected file is not the expected file for import. The expected file name is: " + fileName + "."); } } }
Example 20
Source File: MainDesignerController.java From pmd-designer with BSD 2-Clause "Simplified" License | 4 votes |
private void onOpenFileClicked() { FileChooser chooser = new FileChooser(); chooser.setTitle("Load source from file"); File file = chooser.showOpenDialog(getMainStage()); loadSourceFromFile(file); }