简体   繁体   中英

Javafx and file association : opening the selected file

I have a JavaFX desktop application.

This app save data in "custom" files (".ppz"). In my app, I can browse in files and select the .ppz I want to open.

I've used javafx-maven-plugin and Inno Setup (with the .iss file) to create a .exe installer for Windows and file association. 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. I would like to open the selected file (eg. : like clicking on a .doc is opening MS Word and the right file).

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.

My first mistake was to check args the main method (instead of the start method). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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