简体   繁体   English

JavaFX和文件关联:打开所选文件

[英]Javafx and file association : opening the selected file

I have a JavaFX desktop application. 我有一个JavaFX桌面应用程序。

This app save data in "custom" files (".ppz"). 此应用程序将数据保存在“自定义”文件(“ .ppz”)中。 In my app, I can browse in files and select the .ppz I want to open. 在我的应用程序中,我可以浏览文件并选择要打开的.ppz。

I've used javafx-maven-plugin and Inno Setup (with the .iss file) to create a .exe installer for Windows and file association. 我已经使用javafx-maven-plugin和Inno Setup(带有.iss文件)为Windows和文件关联创建.exe安装程序。 Everything work fine: the installer does his job, my app is running and I've create a file association who work (with a custom icon and everything). 一切正常:安装程序完成工作,我的应用程序正在运行,并且我创建了一个可以正常工作的文件关联(带有自定义图标和所有功能)。

But right now, when I double click on my ".ppz" file, my JavaFX app is just lunching. 但是现在,当我双击“ .ppz”文件时,我的JavaFX应用程序正在午餐。 I would like to open the selected file (eg. : like clicking on a .doc is opening MS Word and the right file). 我想打开选定的文件(例如:就像单击.doc一样,将打开MS Word和正确的文件)。

Any suggestions? 有什么建议么?

Thanks to your comments I've found the solution. 感谢您的评论,我找到了解决方案。

Indeed, that wasn't an Inno Setup setting problem, everything was fine on this side and I just had to check the args within my app. 确实,这不是Inno Setup的设置问题,这一方面的一切都很好,我只需要检查应用程序中的参数即可。

My first mistake was to check args the main method (instead of the start method). 我的第一个错误是检查args主要方法(而不是启动方法)。 The second one was to use the wrong method for that. 第二个方法是使用错误的方法。

Here is a sample who work for me : 这是为我工作的样本:

public void start(Stage stage) {
    FXMLLoader loader = MyOwnLoader.getFxmlLoader();
    MyController controller = loader.getController();
    Parameters params = getParameters();
    log.error(params.getRaw().toString());
    //Also return the filename  : log.info(params.getUnnamed().toString());
    //Don't return the filename : log.info(params.getNamed().toString());
}

Now I just have to process the filename for opening it. 现在,我只需要处理文件名即可打开它。

Thanks for you time and your comments. 感谢您的时间和意见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM