java类javafx.stage.FileChooser的实例源码

SignatureController.java 文件源码 项目:dss-demonstrations 阅读 29 收藏 0 点赞 0 评论 0
private void save(DSSDocument signedDocument) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialFileName(signedDocument.getName());
    MimeType mimeType = signedDocument.getMimeType();
    ExtensionFilter extFilter = new ExtensionFilter(mimeType.getMimeTypeString(), "*." + MimeType.getExtension(mimeType));
    fileChooser.getExtensionFilters().add(extFilter);
    File fileToSave = fileChooser.showSaveDialog(stage);

    if (fileToSave != null) {
        try {
            FileOutputStream fos = new FileOutputStream(fileToSave);
            Utils.copy(signedDocument.openStream(), fos);
            Utils.closeQuietly(fos);
        } catch (Exception e) {
            Alert alert = new Alert(AlertType.ERROR, "Unable to save file : " + e.getMessage(), ButtonType.CLOSE);
            alert.showAndWait();
            return;
        }
    }
}
MultiFileChooserController.java 文件源码 项目:IDBuilderFX 阅读 20 收藏 0 点赞 0 评论 0
public void selectmultifiles(ActionEvent event) {
    FileChooser fc = new FileChooser();
//  fc.setInitialDirectory(new File("C:\\PdfBox_Examples"));
    fc.getExtensionFilters().addAll(new ExtensionFilter("PDF Files", "*.pdf"));
    selectedFiles = fc.showOpenMultipleDialog(null);

    // FIX - Repeating files in list if ReADDED

    if (selectedFiles != null) {
        for (int i = 0; i < selectedFiles.size(); i++) {
            fileslist.getItems().add(selectedFiles.get(i).getAbsolutePath());
            mylist.add(selectedFiles.get(i).getAbsolutePath());
            NOOFFILES++;
        }
    } else {
        // Provide Error in window
        System.out.println("Invalid File");
    }
}
EditLogEntriesTabController.java 文件源码 项目:Recordian 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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();
        }
    }
}
EditorApp.java 文件源码 项目:CleanBT 阅读 17 收藏 0 点赞 0 评论 0
private void initView() {
    centerArea.getChildren().add(centerBtn);
    centerArea.setAlignment(Pos.CENTER);
    fileTree.setEditable(true);
    fileTree.setCellFactory((TreeView<FileTreeItemModel> tree) -> new FileTreeItemCell());
    mainArea.setTop(topArea);
    mainArea.setCenter(centerArea);
    chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("All Torrent", "*.torrent"));

    //将菜单栏添加到顶部
    topArea.getChildren().add(menuBar);
    errorDialog.setTitle("错误");
    infoDialog.setTitle("提示");

    centerBtn.setOnAction(event -> openFile());
}
AddableImage.java 文件源码 项目:fwm 阅读 21 收藏 0 点赞 0 评论 0
public void addImage(){
    FileChooser fc = new FileChooser();
    fc.setTitle("Select an image for this object!");
    fc.getExtensionFilters().addAll(filts);
    // figure out who the owner is here... 
    File selectedFile = fc.showOpenDialog(App.getMainController().getStage());
    File addedFile = null;
    if(selectedFile == null){
        // they couldn't decide what they want. 
        return; 
    }
    else
    {
        addedFile = App.worldFileUtil.addMultimedia(selectedFile);
    }
    if(addedFile == null){
        log.error("Added file was null!");
    }
    else
    {
        setImageTwo(addedFile);
        changeEvent();
    }
}
FileDialogs.java 文件源码 项目:FEFEditor 阅读 28 收藏 0 点赞 0 评论 0
public static void saveFile(Stage stage, byte[] bytes) {
    FileChooser chooser = new FileChooser();
    FileChooser.ExtensionFilter lzFilter = new FileChooser.ExtensionFilter("Compressed Bin File (*.bin.lz)",
            "*.bin.lz");
    FileChooser.ExtensionFilter binFilter = new FileChooser.ExtensionFilter("Bin File (*.bin)",
            "*.bin");
    FileChooser.ExtensionFilter allFilter = new FileChooser.ExtensionFilter("All Files",
            "*");
    chooser.getExtensionFilters().addAll(lzFilter, binFilter, allFilter);
    File file = chooser.showSaveDialog(stage);
    if (file != null) {
        try {
            if (file.getName().endsWith("lz")) {
                byte[] compressed = CompressionUtils.compress(bytes);
                Path path = Paths.get(file.getCanonicalPath());
                Files.write(path, compressed);
            } else
                Files.write(Paths.get(file.getCanonicalPath()), bytes);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
MainWindowController.java 文件源码 项目:shuffleboard 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Choose a new file and save the dashboard to that file.
 */
@FXML
private void saveAs() throws IOException {
  FileChooser chooser = new FileChooser();
  chooser.getExtensionFilters().setAll(
      new FileChooser.ExtensionFilter("Shuffleboard Save File (.json)", "*.json"));
  if (currentFile == null) {
    chooser.setInitialDirectory(Storage.getStorageDir());
    chooser.setInitialFileName("shuffleboard.json");
  } else {
    chooser.setInitialDirectory(currentFile.getAbsoluteFile().getParentFile());
    chooser.setInitialFileName(currentFile.getName());
  }

  File selected = chooser.showSaveDialog(root.getScene().getWindow());

  saveFile(selected);
}
Support.java 文件源码 项目:FEFEditor 阅读 23 收藏 0 点赞 0 评论 0
@SuppressWarnings("unused")
@FXML
private void export() {
    FileChooser chooser = new FileChooser();
    FileChooser.ExtensionFilter lzFilter = new FileChooser.ExtensionFilter("Compressed Bin File (*.bin.lz)", "*.bin.lz");
    FileChooser.ExtensionFilter binFilter = new FileChooser.ExtensionFilter("Bin File (*.bin)", "*.bin");
    FileChooser.ExtensionFilter allFilter = new FileChooser.ExtensionFilter("All Files", "*");
    chooser.getExtensionFilters().addAll(lzFilter, binFilter, allFilter);
    File file = chooser.showSaveDialog(GuiData.getInstance().getStage());
    if (file != null) {
        try {
            if (file.getName().endsWith("lz")) {
                byte[] compressed = CompressionUtils.compress(bin.toBin());
                Path path = Paths.get(file.getCanonicalPath());
                Files.write(path, compressed);
            } else
                Files.write(Paths.get(file.getCanonicalPath()), bin.toBin());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
StvsMenuBarController.java 文件源码 项目:stvs 阅读 27 收藏 0 点赞 0 评论 0
private void openSpec(ActionEvent t) {
    FileChooser fileChooser = FileChooserFactory
            .createOpenFileChooser(SPECIFICATION,
                    rootModel.get().getWorkingdir());
    File chosenFile = fileChooser
            .showOpenDialog(view.getScene().getWindow());
    if (chosenFile == null) {
        return;
    }
    try {
        HybridSpecification spec = ImporterFacade
                .importHybridSpec(chosenFile,
                        ImporterFacade.ImportFormat.XML);
        this.rootModel.get().getHybridSpecifications().add(spec);
        this.rootModel.get().getHistory()
                .addFilename(chosenFile.getAbsolutePath());
        setWorkingDir(chosenFile);
    } catch (IOException | ImportException e) {
        AlertFactory.createAlert(e).showAndWait();
    }
}
FXMLDocumentController.java 文件源码 项目:spring2017java 阅读 20 收藏 0 点赞 0 评论 0
@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);
        }
    }
}
Helper.java 文件源码 项目:Parallator 阅读 31 收藏 0 点赞 0 评论 0
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());
}
SettingsController.java 文件源码 项目:CDN-FX-2.2 阅读 23 收藏 0 点赞 0 评论 0
@FXML
protected void btnTDClickedFile() throws Exception{
    String path2 = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
    path2 = path2.substring(1, path2.lastIndexOf("/")) + "/";
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open encTitleKeys.bin");
    fileChooser.setInitialDirectory(new File(path2));
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("encTitleKeys", "*.bin"));
    File selectedFile = fileChooser.showOpenDialog(btnCancel.getScene().getWindow());

    if(selectedFile != null){
        String path = selectedFile.getPath();
        textTDFile.setText(path);
        path = path.replaceAll(":", "!");
        PropertiesHandler.setProperties(path, "tdfile");
    }
}
CompletedController.java 文件源码 项目:jedai-ui 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Asks the user for a filename with a save file dialog, and saves a CSV with the entity clusters
 */
public void exportBtnHandler() {
    FileChooser fileChooser = new FileChooser();

    // Set extension filter
    FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("CSV File", "*.csv");
    fileChooser.getExtensionFilters().add(extFilter);

    // Show save file dialog
    File file = fileChooser.showSaveDialog(containerVBox.getScene().getWindow());

    if (file != null) {
        // Results export to CSV
        try {
            PrintToFile.toCSV(entityClusters, file.getAbsolutePath());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
FileHandler.java 文件源码 项目:Squid 阅读 26 收藏 0 点赞 0 评论 0
public static File selectSquid25TaskFile(SquidProject squidProject, Window ownerWindow)
        throws SquidException, IOException, JAXBException, SAXException {
    File retVal = null;

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select Squid 2.5 Task File in Excel '.xls");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Squid 2.5 Excel Task Files", "*.xls"));

    File squidTaskFile = fileChooser.showOpenDialog(ownerWindow);

    if (squidTaskFile != null) {
        if (squidTaskFile.getName().toLowerCase(Locale.US).endsWith(".xls")) {
            retVal = squidTaskFile;
        } else {
            throw new SquidException("Filename does not end with '.xls'");
        }
    }

    return retVal;
}
FileHandler.java 文件源码 项目:Squid 阅读 21 收藏 0 点赞 0 评论 0
public static File saveExpressionFileXML(Expression expression, Window ownerWindow)
        throws IOException {

    File retVal = null;

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Expression '.xml' file");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Expression '.xml' files", "*.xml"));
    File mruFolder = new File(squidPersistentState.getMRUExpressionFolderPath());
    fileChooser.setInitialDirectory(mruFolder.isDirectory() ? mruFolder : null);
    fileChooser.setInitialFileName(expression.getName() + ".xml");

    File expressionFileXML = fileChooser.showSaveDialog(ownerWindow);

    if (expressionFileXML != null) {
        retVal = expressionFileXML;
        squidPersistentState.setMRUExpressionFolderPath(expressionFileXML.getParent());
        ((XMLSerializerInterface) expression)
                .serializeXMLObject(expressionFileXML.getAbsolutePath());
    }

    return retVal;
}
FileHandler.java 文件源码 项目:Squid 阅读 18 收藏 0 点赞 0 评论 0
public static File selectExpressionXMLFile(Window ownerWindow)
        throws IOException, JAXBException, SAXException {
    File retVal = null;

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select Expression xml File '.xml");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Expression xml Files", "*.xml"));
    File mruFolder = new File(squidPersistentState.getMRUExpressionFolderPath());
    fileChooser.setInitialDirectory(mruFolder.isDirectory() ? mruFolder : null);

    File expressionFileXML = fileChooser.showOpenDialog(ownerWindow);

    if (expressionFileXML != null) {
        if (expressionFileXML.getName().toLowerCase(Locale.US).endsWith(".xml")) {
            squidPersistentState.setMRUExpressionFolderPath(expressionFileXML.getParent());
            retVal = expressionFileXML;
        } else {
            throw new IOException("Filename does not end with '.xml'");
        }
    }

    return retVal;
}
FileVariableSetter.java 文件源码 项目:voogasalad-ltub 阅读 18 收藏 0 点赞 0 评论 0
public FileVariableSetter(String variableName) {
    super(variableName);
    Button fileChooser= new Button("Choose file");
    fileLabel=new Label("No file chosen");
    FileChooser chooser=new FileChooser();
    chooser.setInitialDirectory(baseDirectory);
    fileChooser.setOnMouseClicked((event)->{
        File file=chooser.showOpenDialog(new Stage());
        if(file!=null){
            File relativePath=new File(baseDirectory.toURI().relativize(file.toURI()).getPath());
            setField(relativePath);
        }
    });
    this.getChildren().addAll(fileChooser,fileLabel);
    ;
}
StvsMenuBarController.java 文件源码 项目:stvs 阅读 26 收藏 0 点赞 0 评论 0
private boolean saveCode(ActionEvent t) {
    // Set the code filename, if no filename set yet
    Code code = rootModel.get().getScenario().getCode();
    if (code.getFilename().isEmpty()) {
        FileChooser fileChooser = FileChooserFactory
                .createSaveFileChooser(CODE,
                        rootModel.get().getWorkingdir());
        File chosenFile = fileChooser
                .showSaveDialog(view.getScene().getWindow());
        if (chosenFile == null) {
            return false;
        }
        code.setFilename(chosenFile.getAbsolutePath());
    }
    // Export the code to the file
    try {
        ExporterFacade.exportCode(code, false);
        return true;
    } catch (IOException e) {
        AlertFactory.createAlert(e).showAndWait();
        return false;
    }
}
FileUtils.java 文件源码 项目:Notebook 阅读 30 收藏 0 点赞 0 评论 0
public static File chooseFile(){

        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("��ѡ���ļ�");
        if(justVisitedDir == null) {
            // ���ó�ʼĿ¼
            fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
        } else {
            fileChooser.setInitialDirectory(justVisitedDir);
        }

        fileChooser.getExtensionFilters().addAll(new ExtensionFilter[]{new ExtensionFilter("Image Files", new String[]{"*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp"}), new ExtensionFilter("JPG", new String[]{"*.jpg"}), new ExtensionFilter("JPEG", new String[]{"*.jpeg"}), new ExtensionFilter("BMP", new String[]{"*.bmp"}), new ExtensionFilter("PNG", new String[]{"*.png"}), new ExtensionFilter("GIF", new String[]{"*.gif"})});
        File file = fileChooser.showOpenDialog(null);
        if(file != null){
            justVisitedDir = file.getParentFile();
        }
        return file;
    }
MenuController.java 文件源码 项目:hygene 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Opens a {@link FileChooser} and sets the parent {@link javafx.stage.Window} as
 * {@link Hygene#getPrimaryStage()#getOwner()}.
 *
 * @param fileChooser the file chooser that needs to be shown to the user
 * @param type        a descriptive type name of the file that needs to be opened
 * @return a file object or {@code null} if no file was selected
 * @throws IOException               if unable to open or parse the file
 * @throws UIInitialisationException if this method was called before {@link Hygene} was instantiated
 */
private File openFileAction(final FileChooser fileChooser, final String type)
        throws UIInitialisationException, IOException {
    final Stage primaryStage = Hygene.getInstance().getPrimaryStage();

    final File recentDirectory = RecentDirectory.get(type);
    if (recentDirectory.exists()) {
        fileChooser.setInitialDirectory(recentDirectory);
    }

    final File file = fileChooser.showOpenDialog(primaryStage.getScene().getWindow());
    if (file == null) {
        return null;
    }

    if (file.getParentFile() != null) {
        RecentDirectory.store(type, file.getParentFile());
    }

    return file;
}
AppController.java 文件源码 项目:Steam-trader-tools 阅读 25 收藏 0 点赞 0 评论 0
@FXML
private void saveNewAppListToXml(ActionEvent event)
{
    JAXBContext context;
    try
    {
        context = JAXBContext.newInstance(UserAppList.class);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        FileChooser fc = new FileChooser();
        File file = fc.showSaveDialog(null);
        if (file != null)
        {
            marshaller.marshal(userAppList, file);
            JFXSnackbar info = new JFXSnackbar(root);
            info.show(I18n.getMessage("savedtoxml") + file.getAbsolutePath(), 3000);
            prefs.put(PreferencesKeys.SAVE_PATH.toString(), file.getAbsolutePath());
        }
    } catch (JAXBException e)
    {
        e.printStackTrace();
    }

}
ItemWeaponMeleController.java 文件源码 项目:drd 阅读 19 收藏 0 点赞 0 评论 0
public void handleSelectImage(MouseEvent mouseEvent) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(imageChooserTitle);
    fileChooser.getExtensionFilters().add(new ExtensionFilter("PNG", "*.png"));
    final File file = fileChooser
        .showOpenDialog(((Node) mouseEvent.getSource()).getScene().getWindow());
    if (file == null) {
        return;
    }

    try {
        final byte[] image = ImageUtils.readImage(file);
        model.imageRaw.set(image);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
HomeController.java 文件源码 项目:SerialAssistant 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 保存数据按钮被点击
 */
@FXML
public void onSaveDataBtnClicked() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("保存到...");
    File file = fileChooser.showSaveDialog(AppDelegate.static_stage);

    if (file == null) {
        receivedToFileCbox.setSelected(false);
        return;
    }

    //解除文件占用
    unlockFile(file);

    //统一换行符
    String data = dataTextArea.getText().replace("\r", "");
    data = data.replace("\n", "\r\n");

    //写入文件
    writeToFile(data, file);

}
FileMenu.java 文件源码 项目:Matcher 阅读 23 收藏 0 点赞 0 评论 0
private void saveMatches() {
    Path path = Gui.requestFile("Save matches file", gui.getScene().getWindow(), Arrays.asList(new FileChooser.ExtensionFilter("Matches", "*.match")), false);
    if (path == null) return;

    if (!path.getFileName().toString().toLowerCase(Locale.ENGLISH).endsWith(".match")) {
        path = path.resolveSibling(path.getFileName().toString()+".match");
    }

    try {
        if (Files.isDirectory(path)) {
            gui.showAlert(AlertType.ERROR, "Save error", "Invalid file selection", "The selected file is a directory.");
        } else if (Files.exists(path)) {
            Files.deleteIfExists(path);
        }

        if (!gui.getMatcher().saveMatches(path)) {
            gui.showAlert(AlertType.WARNING, "Matches save warning", "No matches to save", "There are currently no matched classes, so saving was aborted.");
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return;
    }
}
NativeJFileChooser.java 文件源码 项目:NativeJFileChooser 阅读 22 收藏 0 点赞 0 评论 0
@Override
public void setAcceptAllFileFilterUsed(boolean bool) {
    boolean differs = isAcceptAllFileFilterUsed() ^ bool;
    super.setAcceptAllFileFilterUsed(bool);
    if (!FX_AVAILABLE) {
        return;
    }
    if (differs) {
        if (bool) {
            fileChooser.getExtensionFilters()
                    .add(new FileChooser.ExtensionFilter("All files", "*.*"));
        } else {
            for (Iterator<FileChooser.ExtensionFilter> it
                    = fileChooser.getExtensionFilters().iterator(); it.hasNext();) {
                FileChooser.ExtensionFilter filter = it.next();
                if (filter.getExtensions().size() == 1
                        && filter.getExtensions().contains("*.*")) {
                    it.remove();
                }
            }
        }
    }
}
Ludwig.java 文件源码 项目:candlelight 阅读 23 收藏 0 点赞 0 评论 0
private void loadDungeon(Stage stage)
{
    FileChooser chooser = new FileChooser();
    chooser.setInitialFileName("dungeon.json");
    File file = chooser.showOpenDialog(stage);

    if (file != null)
    {
        try
        {
            JSONObject data;
            BufferedReader reader = new BufferedReader(new FileReader(file));
            JSONFormatParser parser = new JSONFormatParser(256);
            data = (JSONObject) parser.parse(reader);
            reader.close();
            this.dungeon = Dungeon.loadFromJSON(data);
            this.dungeonHandler = new DungeonHandler(this.dungeon);
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}
NetPane.java 文件源码 项目:file-transfer 阅读 19 收藏 0 点赞 0 评论 0
protected void createSelectButton() {
    selectButton = new Button("Select...");
    selectButton.setOnAction(event -> {
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Select file");
        if (LastVisitedDirectory.getInstance().wasVisited()) {
            fileChooser.setInitialDirectory(new File(LastVisitedDirectory.getInstance().getPath()));
        }
        try {
            String newPath = getFilePath(fileChooser, primaryStage);
            LastVisitedDirectory.getInstance().setLastVisitedDirectory(newPath);
            pathTextField.setText(newPath);
        } catch (NullPointerException e) {
            System.out.println("Canceled");
        }
    });
}
Restore.java 文件源码 项目:gatepass 阅读 19 收藏 0 点赞 0 评论 0
public String getRestore(){
    String backuppath ="";
    File file;
    FileChooser fileChooser= new FileChooser();
    file = fileChooser.showOpenDialog(stage);
    fileChooser.setTitle("Select Photo");
       if (file != null) {
        fileChooser.getExtensionFilters().addAll(
                new FileChooser.ExtensionFilter("All Images", "*.*"),
                new FileChooser.ExtensionFilter("SQL", "*.sql")
       );

        backuppath = file.getAbsolutePath();      
}
    return backuppath;
}
DownloaderController.java 文件源码 项目:tenhou-visualizer 阅读 20 收藏 0 点赞 0 评论 0
public void exportMjlog(ActionEvent actionEvent) throws IOException {
    if (this.tableView.getSelectionModel().getSelectedItem() != null) {
        InfoSchema infoSchema = this.tableView.getSelectionModel().getSelectedItem();
        String content = this.databaseService.findMjlogById(infoSchema.getId());
        if (content != null) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setInitialFileName(infoSchema.getId());
            fileChooser.setTitle("Save mjlog File");
            fileChooser.getExtensionFilters().add(
                    new FileChooser.ExtensionFilter("mjlog Files", "*.mjlog"));
            File selectedFile = fileChooser.showSaveDialog(this.dateListView.getScene().getWindow());
            if (selectedFile != null) {
                Files.copy(new ByteArrayInputStream(content.getBytes()), selectedFile.toPath());
            }
        }
    }
}
MainGuiController.java 文件源码 项目:OpenDiabetes 阅读 24 收藏 0 点赞 0 评论 0
@FXML
private void handleButtonBrowseAbbott(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_ABBOTT_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.TXT_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        abbottTextField.setText(sb.toString().substring(0, sb.length() - 1));
        abbottCheckBox.setSelected(true);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号